diff --git a/components/ratgdo/binary_sensor/ratgdo_binary_sensor.cpp b/components/ratgdo/binary_sensor/ratgdo_binary_sensor.cpp index 2a8f77f..46b023d 100644 --- a/components/ratgdo/binary_sensor/ratgdo_binary_sensor.cpp +++ b/components/ratgdo/binary_sensor/ratgdo_binary_sensor.cpp @@ -1,30 +1,30 @@ #include "ratgdo_binary_sensor.h" -#include "esphome/core/log.h" #include "../ratgdo_state.h" +#include "esphome/core/log.h" namespace esphome { namespace ratgdo { -static const char *const TAG = "ratgdo.binary_sensor"; + static const char* const TAG = "ratgdo.binary_sensor"; -void RATGDOBinarySensor::dump_config() { - LOG_BINARY_SENSOR("", "RATGDO BinarySensor", this); - ESP_LOGCONFIG(TAG, " Type: %s", this->type_ == SensorType::RATGDO_SENSOR_MOTION ? "Motion" : "Obstruction"); -} -void RATGDOBinarySensor::on_motion_state(esphome::ratgdo::MotionState state) { - if (this->type_ == SensorType::RATGDO_SENSOR_MOTION) - this->publish_state(state == esphome::ratgdo::MotionState::MOTION_STATE_DETECTED); -} -void RATGDOBinarySensor::on_obstruction_state(esphome::ratgdo::ObstructionState state) { - if (this->type_ == SensorType::RATGDO_SENSOR_OBSTRUCTION) - this->publish_state(state == esphome::ratgdo::ObstructionState::OBSTRUCTION_STATE_OBSTRUCTED); -} -void RATGDOBinarySensor::on_door_state(esphome::ratgdo::DoorState state) {} -void RATGDOBinarySensor::on_light_state(esphome::ratgdo::LightState state) {} -void RATGDOBinarySensor::on_lock_state(esphome::ratgdo::LockState state) {} - - - -} // namespace ratgdo -} // namespace esphome + void RATGDOBinarySensor::dump_config() + { + LOG_BINARY_SENSOR("", "RATGDO BinarySensor", this); + ESP_LOGCONFIG(TAG, " Type: %s", this->type_ == SensorType::RATGDO_SENSOR_MOTION ? "Motion" : "Obstruction"); + } + void RATGDOBinarySensor::on_motion_state(esphome::ratgdo::MotionState state) + { + if (this->type_ == SensorType::RATGDO_SENSOR_MOTION) + this->publish_state(state == esphome::ratgdo::MotionState::MOTION_STATE_DETECTED); + } + void RATGDOBinarySensor::on_obstruction_state(esphome::ratgdo::ObstructionState state) + { + if (this->type_ == SensorType::RATGDO_SENSOR_OBSTRUCTION) + this->publish_state(state == esphome::ratgdo::ObstructionState::OBSTRUCTION_STATE_OBSTRUCTED); + } + void RATGDOBinarySensor::on_door_state(esphome::ratgdo::DoorState state) { } + void RATGDOBinarySensor::on_light_state(esphome::ratgdo::LightState state) { } + void RATGDOBinarySensor::on_lock_state(esphome::ratgdo::LockState state) { } +} // namespace ratgdo +} // namespace esphome diff --git a/components/ratgdo/binary_sensor/ratgdo_binary_sensor.h b/components/ratgdo/binary_sensor/ratgdo_binary_sensor.h index 82005f7..8304c43 100644 --- a/components/ratgdo/binary_sensor/ratgdo_binary_sensor.h +++ b/components/ratgdo/binary_sensor/ratgdo_binary_sensor.h @@ -1,32 +1,30 @@ #pragma once -#include "esphome/core/component.h" +#include "../ratgdo.h" #include "../ratgdo_child.h" #include "../ratgdo_state.h" -#include "../ratgdo.h" #include "esphome/components/binary_sensor/binary_sensor.h" +#include "esphome/core/component.h" namespace esphome { namespace ratgdo { -enum SensorType { - RATGDO_SENSOR_MOTION, - RATGDO_SENSOR_OBSTRUCTION, -}; + enum SensorType { + RATGDO_SENSOR_MOTION, + RATGDO_SENSOR_OBSTRUCTION, + }; -class RATGDOBinarySensor : public binary_sensor::BinarySensor, public RATGDOClient, public Component { - public: - void dump_config() override; - void set_type(SensorType type) { type_ = type_; } + class RATGDOBinarySensor : public binary_sensor::BinarySensor, public RATGDOClient, public Component { + public: + void dump_config() override; + void set_type(SensorType type) { type_ = type_; } - void on_motion_state(esphome::ratgdo::MotionState state) override; - void on_obstruction_state(esphome::ratgdo::ObstructionState state) override; + void on_motion_state(esphome::ratgdo::MotionState state) override; + void on_obstruction_state(esphome::ratgdo::ObstructionState state) override; - protected: - SensorType type_; - -}; - -} // namespace ratgdo -} // namespace esphome + protected: + SensorType type_; + }; +} // namespace ratgdo +} // namespace esphome