binary sensor

This commit is contained in:
J. Nick Koston 2023-06-07 11:31:02 -05:00
parent 0a76ee5f45
commit ab431adbb9
No known key found for this signature in database
3 changed files with 7 additions and 0 deletions

View File

@ -30,3 +30,4 @@ async def to_code(config):
await binary_sensor.register_binary_sensor(var, config) await binary_sensor.register_binary_sensor(var, config)
await cg.register_component(var, config) await cg.register_component(var, config)
await register_ratgdo_child(var, config) await register_ratgdo_child(var, config)
cg.add(var.set_type(var, config[CONF_TYPE]))

View File

@ -9,6 +9,8 @@ static const char *const TAG = "ratgdo.binary_sensor";
void RATGDOBinarySensor::dump_config() { void RATGDOBinarySensor::dump_config() {
LOG_BINARY_SENSOR("", "RATGDO BinarySensor", this); LOG_BINARY_SENSOR("", "RATGDO BinarySensor", this);
LOG_PIN(" Type: ", this->type_);
} }
void RATGDOBinarySensor::on_door_state(esphome::ratgdo::DoorState state) {} void RATGDOBinarySensor::on_door_state(esphome::ratgdo::DoorState state) {}

View File

@ -12,6 +12,7 @@ namespace ratgdo {
class RATGDOBinarySensor : public binary_sensor::BinarySensor, public RATGDOClient, public Component { class RATGDOBinarySensor : public binary_sensor::BinarySensor, public RATGDOClient, public Component {
public: public:
void dump_config() override; void dump_config() override;
void set_type(const std::string &type_) { this->type_ = type_; }
void on_door_state(esphome::ratgdo::DoorState state) override; void on_door_state(esphome::ratgdo::DoorState state) override;
void on_light_state(esphome::ratgdo::LightState state) override; void on_light_state(esphome::ratgdo::LightState state) override;
@ -19,6 +20,9 @@ class RATGDOBinarySensor : public binary_sensor::BinarySensor, public RATGDOClie
void on_motion_state(esphome::ratgdo::MotionState state) override; void on_motion_state(esphome::ratgdo::MotionState state) override;
void on_obstruction_state(esphome::ratgdo::ObstructionState state) override; void on_obstruction_state(esphome::ratgdo::ObstructionState state) override;
protected:
std::string type_;
}; };
} // namespace ratgdo } // namespace ratgdo