diff --git a/components/ratgdo/binary_sensor/__init__.py b/components/ratgdo/binary_sensor/__init__.py index 423203f..f98da9f 100644 --- a/components/ratgdo/binary_sensor/__init__.py +++ b/components/ratgdo/binary_sensor/__init__.py @@ -30,3 +30,4 @@ async def to_code(config): await binary_sensor.register_binary_sensor(var, config) await cg.register_component(var, config) await register_ratgdo_child(var, config) + cg.add(var.set_type(var, config[CONF_TYPE])) diff --git a/components/ratgdo/binary_sensor/ratgdo_binary_sensor.cpp b/components/ratgdo/binary_sensor/ratgdo_binary_sensor.cpp index 762d06d..3361ab7 100644 --- a/components/ratgdo/binary_sensor/ratgdo_binary_sensor.cpp +++ b/components/ratgdo/binary_sensor/ratgdo_binary_sensor.cpp @@ -9,6 +9,8 @@ static const char *const TAG = "ratgdo.binary_sensor"; void RATGDOBinarySensor::dump_config() { LOG_BINARY_SENSOR("", "RATGDO BinarySensor", this); + LOG_PIN(" Type: ", this->type_); + } void RATGDOBinarySensor::on_door_state(esphome::ratgdo::DoorState state) {} diff --git a/components/ratgdo/binary_sensor/ratgdo_binary_sensor.h b/components/ratgdo/binary_sensor/ratgdo_binary_sensor.h index 6329abd..3d22335 100644 --- a/components/ratgdo/binary_sensor/ratgdo_binary_sensor.h +++ b/components/ratgdo/binary_sensor/ratgdo_binary_sensor.h @@ -12,6 +12,7 @@ namespace ratgdo { class RATGDOBinarySensor : public binary_sensor::BinarySensor, public RATGDOClient, public Component { public: 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_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_obstruction_state(esphome::ratgdo::ObstructionState state) override; + protected: + std::string type_; + }; } // namespace ratgdo