2023-06-07 15:06:51 +00:00
|
|
|
#include "ratgdo_state.h"
|
|
|
|
|
|
|
|
namespace esphome {
|
|
|
|
namespace ratgdo {
|
|
|
|
|
2023-06-24 20:38:44 +00:00
|
|
|
LightState light_state_toggle(LightState state)
|
|
|
|
{
|
|
|
|
switch (state) {
|
2023-07-03 16:47:00 +00:00
|
|
|
case LightState::OFF:
|
|
|
|
return LightState::ON;
|
|
|
|
case LightState::ON:
|
|
|
|
return LightState::OFF;
|
2023-06-24 20:38:44 +00:00
|
|
|
// 2 and 3 appears sometimes
|
2023-07-03 16:47:00 +00:00
|
|
|
case LightState::UNKNOWN:
|
2023-06-24 20:38:44 +00:00
|
|
|
default:
|
2023-07-03 16:47:00 +00:00
|
|
|
return LightState::UNKNOWN;
|
2023-06-07 15:06:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-06-24 20:38:44 +00:00
|
|
|
LockState lock_state_toggle(LockState state)
|
|
|
|
{
|
|
|
|
switch (state) {
|
2023-07-03 16:47:00 +00:00
|
|
|
case LockState::UNLOCKED:
|
|
|
|
return LockState::LOCKED;
|
|
|
|
case LockState::LOCKED:
|
|
|
|
return LockState::UNLOCKED;
|
2023-06-24 20:38:44 +00:00
|
|
|
// 2 and 3 appears sometimes
|
2023-07-03 16:47:00 +00:00
|
|
|
case LockState::UNKNOWN:
|
2023-06-09 23:04:29 +00:00
|
|
|
default:
|
2023-07-03 16:47:00 +00:00
|
|
|
return LockState::UNKNOWN;
|
2023-06-09 23:04:29 +00:00
|
|
|
}
|
2023-06-09 23:04:32 +00:00
|
|
|
}
|
2023-06-09 23:04:29 +00:00
|
|
|
|
2024-01-18 22:25:08 +00:00
|
|
|
LearnState learn_state_toggle(LearnState state)
|
|
|
|
{
|
|
|
|
switch (state) {
|
|
|
|
case LearnState::ACTIVE:
|
|
|
|
return LearnState::INACTIVE;
|
|
|
|
case LearnState::INACTIVE:
|
|
|
|
return LearnState::ACTIVE;
|
|
|
|
// 2 and 3 appears sometimes
|
|
|
|
case LearnState::UNKNOWN:
|
|
|
|
default:
|
|
|
|
return LearnState::UNKNOWN;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-06-07 15:06:51 +00:00
|
|
|
} // namespace ratgdo
|
|
|
|
} // namespace esphome
|