fix
This commit is contained in:
parent
28245dc131
commit
511741f213
|
@ -33,5 +33,5 @@ async def to_code(config):
|
||||||
var = cg.new_Pvariable(config[CONF_ID])
|
var = cg.new_Pvariable(config[CONF_ID])
|
||||||
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)
|
||||||
cg.add(var.set_type(config[CONF_TYPE]))
|
cg.add(var.set_binary_sensor_type(config[CONF_TYPE]))
|
||||||
await register_ratgdo_child(var, config)
|
await register_ratgdo_child(var, config)
|
||||||
|
|
|
@ -14,14 +14,14 @@ namespace ratgdo {
|
||||||
}
|
}
|
||||||
void RATGDOBinarySensor::on_motion_state(MotionState state)
|
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);
|
ESP_LOGD(TAG, "name: %s this->type_:%d on_motion_state: %d", this->get_name(), this->binary_sensor_type_, state);
|
||||||
if (this->type_ == SensorType::RATGDO_SENSOR_MOTION)
|
if (this->binary_sensor_type_ == SensorType::RATGDO_SENSOR_MOTION)
|
||||||
this->publish_state(state == MotionState::MOTION_STATE_DETECTED);
|
this->publish_state(state == MotionState::MOTION_STATE_DETECTED);
|
||||||
}
|
}
|
||||||
void RATGDOBinarySensor::on_obstruction_state(ObstructionState state)
|
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);
|
ESP_LOGD(TAG, "name: %s this->type_:%d on_obstruction_state: %d", this->get_name(), this->binary_sensor_type_, state);
|
||||||
if (this->type_ == SensorType::RATGDO_SENSOR_OBSTRUCTION)
|
if (this->binary_sensor_type_ == SensorType::RATGDO_SENSOR_OBSTRUCTION)
|
||||||
this->publish_state(state == ObstructionState::OBSTRUCTION_STATE_OBSTRUCTED);
|
this->publish_state(state == ObstructionState::OBSTRUCTION_STATE_OBSTRUCTED);
|
||||||
}
|
}
|
||||||
void RATGDOBinarySensor::on_door_state(DoorState state) { }
|
void RATGDOBinarySensor::on_door_state(DoorState state) { }
|
||||||
|
|
|
@ -17,7 +17,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(SensorType type) { this->type_ = type_; }
|
void set_type(SensorType type) { this->binary_sensor_type_ = type_; }
|
||||||
|
|
||||||
void on_motion_state(MotionState state) override;
|
void on_motion_state(MotionState state) override;
|
||||||
void on_obstruction_state(ObstructionState state) override;
|
void on_obstruction_state(ObstructionState state) override;
|
||||||
|
@ -26,7 +26,7 @@ namespace ratgdo {
|
||||||
void on_lock_state(LockState state) override;
|
void on_lock_state(LockState state) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
SensorType type_;
|
SensorType binary_sensor_type_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace ratgdo
|
} // namespace ratgdo
|
||||||
|
|
Loading…
Reference in New Issue