esphome-ratgdo/components/ratgdo/cover/ratgdo_cover.cpp

56 lines
1.8 KiB
C++
Raw Normal View History

2023-06-07 17:01:36 +00:00
#include "ratgdo_cover.h"
2023-06-07 16:56:55 +00:00
#include "../ratgdo_state.h"
#include "esphome/core/log.h"
namespace esphome {
namespace ratgdo {
using namespace esphome::cover;
static const char* const TAG = "ratgdo.cover";
void RATGDOCover::dump_config()
{
LOG_COVER("", "RATGDO Cover", this);
}
void RATGDOCover::on_motion_state(esphome::ratgdo::MotionState state) { }
void RATGDOCover::on_obstruction_state(esphome::ratgdo::ObstructionState state) { }
void RATGDOCover::on_door_state(esphome::ratgdo::DoorState state)
{
2023-06-07 17:01:36 +00:00
switch (state) {
case esphome::ratgdo::DoorState::DOOR_STATE_OPEN:
2023-06-07 16:56:55 +00:00
this->position = COVER_OPEN;
2023-06-07 17:01:36 +00:00
this->current_operation = COVER_OPERATION_IDLE;
case esphome::ratgdo::DoorState::DOOR_STATE_CLOSED:
this->position = COVER_CLOSED;
this->current_operation = COVER_OPERATION_IDLE;
case esphome::ratgdo::DoorState::DOOR_STATE_OPENING:
this->current_operation = COVER_OPERATION_OPENING;
case esphome::ratgdo::DoorState::DOOR_STATE_CLOSING:
this->current_operation = COVER_OPERATION_CLOSING;
case esphome::ratgdo::DoorState::DOOR_STATE_STOPPED:
default:
this->current_operation = COVER_OPERATION_IDLE;
break;
}
2023-06-07 16:56:55 +00:00
this->publish_state();
}
void RATGDOCover::on_light_state(esphome::ratgdo::LightState state) { }
void RATGDOCover::on_lock_state(esphome::ratgdo::LockState state) { }
CoverTraits RATGDOCover::get_traits()
{
auto traits = CoverTraits();
traits.set_supports_stop(true);
traits.set_supports_position(false);
traits.set_supports_tilt(false);
traits.set_is_assumed_state(false);
return traits;
}
2023-06-07 17:04:22 +00:00
void RATGDOCover::control(const CoverCall& call) { }
2023-06-07 16:56:55 +00:00
} // namespace ratgdo
} // namespace esphome