Introduce dummy class
This commit is contained in:
parent
ad1cc45768
commit
dd832447a6
2 changed files with 15 additions and 7 deletions
|
@ -236,10 +236,8 @@ void tw7100Component::update_sensor(std::pair<std::string, std::string> data) {
|
||||||
#endif
|
#endif
|
||||||
} else if (cmd == "SIGNAL") {
|
} else if (cmd == "SIGNAL") {
|
||||||
ESP_LOGV(TAG, "updating signal sensors");
|
ESP_LOGV(TAG, "updating signal sensors");
|
||||||
#ifdef USE_BINARY_SENSOR
|
|
||||||
int value = std::stoi(value_string);
|
int value = std::stoi(value_string);
|
||||||
if (has_signal_) has_signal_->publish_state(value > 0);
|
has_signal_->publish_state(value > 0);
|
||||||
#endif
|
|
||||||
if (signal_status_) signal_status_->publish_state(value);
|
if (signal_status_) signal_status_->publish_state(value);
|
||||||
} else if (cmd == "LUMINANCE") {
|
} else if (cmd == "LUMINANCE") {
|
||||||
ESP_LOGV(TAG, "updating luminance sensors");
|
ESP_LOGV(TAG, "updating luminance sensors");
|
||||||
|
|
18
tw7100.h
18
tw7100.h
|
@ -30,6 +30,18 @@
|
||||||
#include "number/tw7100_number.h"
|
#include "number/tw7100_number.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef USE_BINARY_SENSOR
|
||||||
|
namespace esphome {
|
||||||
|
namespace binary_sensor {
|
||||||
|
class BinarySensor : public Component {
|
||||||
|
private:
|
||||||
|
public:
|
||||||
|
void publish_state(bool state) { ESP_LOGW("dummy_binary_sensor", "skipping updating value for this unconfigured sensor"); };
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace esphome {
|
namespace esphome {
|
||||||
namespace tw7100 {
|
namespace tw7100 {
|
||||||
|
|
||||||
|
@ -121,10 +133,8 @@ class tw7100Component : public PollingComponent, public uart::UARTDevice {
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
#ifdef USE_BINARY_SENSOR
|
binary_sensor::BinarySensor *powered_ = new binary_sensor::BinarySensor();
|
||||||
binary_sensor::BinarySensor *powered_{nullptr};
|
binary_sensor::BinarySensor *has_signal_ = new binary_sensor::BinarySensor();
|
||||||
binary_sensor::BinarySensor *has_signal_{nullptr};
|
|
||||||
#endif
|
|
||||||
#ifdef USE_SENSOR
|
#ifdef USE_SENSOR
|
||||||
sensor::Sensor *lamp_hours_{nullptr};
|
sensor::Sensor *lamp_hours_{nullptr};
|
||||||
sensor::Sensor *power_status_{nullptr};
|
sensor::Sensor *power_status_{nullptr};
|
||||||
|
|
Loading…
Add table
Reference in a new issue