binary sensor
This commit is contained in:
parent
205bbc2066
commit
b797256ef4
|
@ -1,21 +1,24 @@
|
||||||
#include "ratgdo_binary_sensor.h"
|
#include "ratgdo_binary_sensor.h"
|
||||||
#include "esphome/core/log.h"
|
|
||||||
#include "../ratgdo_state.h"
|
#include "../ratgdo_state.h"
|
||||||
|
#include "esphome/core/log.h"
|
||||||
|
|
||||||
namespace esphome {
|
namespace esphome {
|
||||||
namespace ratgdo {
|
namespace ratgdo {
|
||||||
|
|
||||||
static const char* const TAG = "ratgdo.binary_sensor";
|
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);
|
||||||
ESP_LOGCONFIG(TAG, " Type: %s", this->type_ == SensorType::RATGDO_SENSOR_MOTION ? "Motion" : "Obstruction");
|
ESP_LOGCONFIG(TAG, " Type: %s", this->type_ == SensorType::RATGDO_SENSOR_MOTION ? "Motion" : "Obstruction");
|
||||||
}
|
}
|
||||||
void RATGDOBinarySensor::on_motion_state(esphome::ratgdo::MotionState state) {
|
void RATGDOBinarySensor::on_motion_state(esphome::ratgdo::MotionState state)
|
||||||
|
{
|
||||||
if (this->type_ == SensorType::RATGDO_SENSOR_MOTION)
|
if (this->type_ == SensorType::RATGDO_SENSOR_MOTION)
|
||||||
this->publish_state(state == esphome::ratgdo::MotionState::MOTION_STATE_DETECTED);
|
this->publish_state(state == esphome::ratgdo::MotionState::MOTION_STATE_DETECTED);
|
||||||
}
|
}
|
||||||
void RATGDOBinarySensor::on_obstruction_state(esphome::ratgdo::ObstructionState state) {
|
void RATGDOBinarySensor::on_obstruction_state(esphome::ratgdo::ObstructionState state)
|
||||||
|
{
|
||||||
if (this->type_ == SensorType::RATGDO_SENSOR_OBSTRUCTION)
|
if (this->type_ == SensorType::RATGDO_SENSOR_OBSTRUCTION)
|
||||||
this->publish_state(state == esphome::ratgdo::ObstructionState::OBSTRUCTION_STATE_OBSTRUCTED);
|
this->publish_state(state == esphome::ratgdo::ObstructionState::OBSTRUCTION_STATE_OBSTRUCTED);
|
||||||
}
|
}
|
||||||
|
@ -23,8 +26,5 @@ void RATGDOBinarySensor::on_door_state(esphome::ratgdo::DoorState state) {}
|
||||||
void RATGDOBinarySensor::on_light_state(esphome::ratgdo::LightState state) { }
|
void RATGDOBinarySensor::on_light_state(esphome::ratgdo::LightState state) { }
|
||||||
void RATGDOBinarySensor::on_lock_state(esphome::ratgdo::LockState state) { }
|
void RATGDOBinarySensor::on_lock_state(esphome::ratgdo::LockState state) { }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} // namespace ratgdo
|
} // namespace ratgdo
|
||||||
} // namespace esphome
|
} // namespace esphome
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "esphome/core/component.h"
|
#include "../ratgdo.h"
|
||||||
#include "../ratgdo_child.h"
|
#include "../ratgdo_child.h"
|
||||||
#include "../ratgdo_state.h"
|
#include "../ratgdo_state.h"
|
||||||
#include "../ratgdo.h"
|
|
||||||
#include "esphome/components/binary_sensor/binary_sensor.h"
|
#include "esphome/components/binary_sensor/binary_sensor.h"
|
||||||
|
#include "esphome/core/component.h"
|
||||||
|
|
||||||
namespace esphome {
|
namespace esphome {
|
||||||
namespace ratgdo {
|
namespace ratgdo {
|
||||||
|
@ -24,9 +24,7 @@ class RATGDOBinarySensor : public binary_sensor::BinarySensor, public RATGDOClie
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
SensorType type_;
|
SensorType type_;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace ratgdo
|
} // namespace ratgdo
|
||||||
} // namespace esphome
|
} // namespace esphome
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue