2023-06-07 15:06:51 +00:00
|
|
|
#include "ratgdo_state.h"
|
|
|
|
|
|
|
|
#include "esphome/core/log.h"
|
|
|
|
|
|
|
|
namespace esphome {
|
|
|
|
namespace ratgdo {
|
|
|
|
|
|
|
|
const char* door_state_to_string(DoorState state)
|
|
|
|
{
|
|
|
|
switch (state) {
|
|
|
|
case DOOR_STATE_OPEN:
|
|
|
|
return "OPEN";
|
|
|
|
case DOOR_STATE_CLOSED:
|
|
|
|
return "CLOSED";
|
|
|
|
case DOOR_STATE_STOPPED:
|
|
|
|
return "STOPPED";
|
|
|
|
case DOOR_STATE_OPENING:
|
|
|
|
return "OPENING";
|
|
|
|
case DOOR_STATE_CLOSING:
|
|
|
|
return "CLOSING";
|
|
|
|
case DOOR_STATE_UNKNOWN:
|
|
|
|
default:
|
|
|
|
return "UNKNOWN";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const char* light_state_to_string(LightState state)
|
|
|
|
{
|
|
|
|
switch (state) {
|
|
|
|
case LIGHT_STATE_OFF:
|
|
|
|
return "OFF";
|
|
|
|
case LIGHT_STATE_ON:
|
|
|
|
return "ON";
|
2023-06-07 20:52:51 +00:00
|
|
|
// 2 and 3 appears sometimes
|
2023-06-07 15:06:51 +00:00
|
|
|
case LIGHT_STATE_UNKNOWN:
|
|
|
|
default:
|
|
|
|
return "UNKNOWN";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const char* lock_state_to_string(LockState state)
|
|
|
|
{
|
|
|
|
switch (state) {
|
|
|
|
case LOCK_STATE_UNLOCKED:
|
|
|
|
return "UNLOCKED";
|
|
|
|
case LOCK_STATE_LOCKED:
|
|
|
|
return "LOCKED";
|
|
|
|
case LOCK_STATE_UNKNOWN:
|
|
|
|
default:
|
|
|
|
return "UNKNOWN";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const char* motion_state_to_string(MotionState state)
|
|
|
|
{
|
|
|
|
switch (state) {
|
|
|
|
case MOTION_STATE_DETECTED:
|
|
|
|
return "DETECTED";
|
2023-06-08 02:40:07 +00:00
|
|
|
case MOTION_STATE_CLEAR:
|
2023-06-07 15:06:51 +00:00
|
|
|
default:
|
|
|
|
return "CLEAR";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-06-08 02:40:07 +00:00
|
|
|
const char* motor_state_to_string(MotorState state)
|
|
|
|
{
|
|
|
|
switch (state) {
|
|
|
|
case MOTOR_STATE_ON:
|
|
|
|
return "ON";
|
|
|
|
case MOTOR_STATE_OFF:
|
|
|
|
default:
|
|
|
|
return "OFF";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-06-07 15:06:51 +00:00
|
|
|
const char* obstruction_state_to_string(ObstructionState state)
|
|
|
|
{
|
|
|
|
switch (state) {
|
|
|
|
case OBSTRUCTION_STATE_CLEAR:
|
|
|
|
return "CLEAR";
|
|
|
|
case OBSTRUCTION_STATE_OBSTRUCTED:
|
|
|
|
return "OBSTRUCTED";
|
|
|
|
case OBSTRUCTION_STATE_UNKNOWN:
|
|
|
|
default:
|
|
|
|
return "UNKNOWN";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace ratgdo
|
|
|
|
} // namespace esphome
|