This commit is contained in:
J. Nick Koston 2023-06-07 14:48:20 -05:00
parent 28245dc131
commit 511741f213
No known key found for this signature in database
3 changed files with 7 additions and 7 deletions

View File

@ -33,5 +33,5 @@ async def to_code(config):
var = cg.new_Pvariable(config[CONF_ID])
await binary_sensor.register_binary_sensor(var, config)
await cg.register_component(var, config)
cg.add(var.set_type(config[CONF_TYPE]))
cg.add(var.set_binary_sensor_type(config[CONF_TYPE]))
await register_ratgdo_child(var, config)

View File

@ -14,14 +14,14 @@ namespace ratgdo {
}
void RATGDOBinarySensor::on_motion_state(MotionState state)
{
ESP_LOGD(TAG, "name: %s this->type_:%d on_motion_state: %d", this->get_name(), this->type_, state);
if (this->type_ == SensorType::RATGDO_SENSOR_MOTION)
ESP_LOGD(TAG, "name: %s this->type_:%d on_motion_state: %d", this->get_name(), this->binary_sensor_type_, state);
if (this->binary_sensor_type_ == SensorType::RATGDO_SENSOR_MOTION)
this->publish_state(state == MotionState::MOTION_STATE_DETECTED);
}
void RATGDOBinarySensor::on_obstruction_state(ObstructionState state)
{
ESP_LOGD(TAG, "name: %s this->type_:%d on_obstruction_state: %d", this->get_name(), this->type_, state);
if (this->type_ == SensorType::RATGDO_SENSOR_OBSTRUCTION)
ESP_LOGD(TAG, "name: %s this->type_:%d on_obstruction_state: %d", this->get_name(), this->binary_sensor_type_, state);
if (this->binary_sensor_type_ == SensorType::RATGDO_SENSOR_OBSTRUCTION)
this->publish_state(state == ObstructionState::OBSTRUCTION_STATE_OBSTRUCTED);
}
void RATGDOBinarySensor::on_door_state(DoorState state) { }

View File

@ -17,7 +17,7 @@ namespace ratgdo {
class RATGDOBinarySensor : public binary_sensor::BinarySensor, public RATGDOClient, public Component {
public:
void dump_config() override;
void set_type(SensorType type) { this->type_ = type_; }
void set_type(SensorType type) { this->binary_sensor_type_ = type_; }
void on_motion_state(MotionState state) override;
void on_obstruction_state(ObstructionState state) override;
@ -26,7 +26,7 @@ namespace ratgdo {
void on_lock_state(LockState state) override;
protected:
SensorType type_;
SensorType binary_sensor_type_;
};
} // namespace ratgdo