Compare commits
1 commit
main
...
dummy_clas
Author | SHA1 | Date | |
---|---|---|---|
sqozz | 8ae2dd3300 |
|
@ -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");
|
||||||
|
|
40
tw7100.h
40
tw7100.h
|
@ -30,6 +30,27 @@
|
||||||
#include "number/tw7100_number.h"
|
#include "number/tw7100_number.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
namespace esphome {
|
||||||
|
#ifndef USE_SENSOR
|
||||||
|
namespace sensor {
|
||||||
|
class Sensor : public Component {
|
||||||
|
public:
|
||||||
|
void publish_state(float state) { ESP_LOGW("dummy_sensor", "skipping updating value for this unconfigured sensor"); };
|
||||||
|
};
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef USE_BINARY_SENSOR
|
||||||
|
namespace binary_sensor {
|
||||||
|
class BinarySensor : public Component {
|
||||||
|
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 {
|
||||||
|
|
||||||
|
@ -119,18 +140,17 @@ class tw7100Component : public PollingComponent, public uart::UARTDevice {
|
||||||
void set_set_destrength(tw7100::tw7100Number *number_) { this->destrength_number_ = number_; }
|
void set_set_destrength(tw7100::tw7100Number *number_) { this->destrength_number_ = number_; }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
private:
|
||||||
|
binary_sensor::BinarySensor *dummy_binary_sensor = new binary_sensor::BinarySensor();
|
||||||
|
sensor::Sensor *dummy_sensor = new sensor::Sensor();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
#ifdef USE_BINARY_SENSOR
|
binary_sensor::BinarySensor *powered_ = dummy_binary_sensor;
|
||||||
binary_sensor::BinarySensor *powered_{nullptr};
|
binary_sensor::BinarySensor *has_signal_ = dummy_binary_sensor;
|
||||||
binary_sensor::BinarySensor *has_signal_{nullptr};
|
sensor::Sensor *lamp_hours_ = dummy_sensor;
|
||||||
#endif
|
sensor::Sensor *power_status_ = dummy_sensor;
|
||||||
#ifdef USE_SENSOR
|
sensor::Sensor *signal_status_ = dummy_sensor;
|
||||||
sensor::Sensor *lamp_hours_{nullptr};
|
sensor::Sensor *luminance_level_ = dummy_sensor;
|
||||||
sensor::Sensor *power_status_{nullptr};
|
|
||||||
sensor::Sensor *signal_status_{nullptr};
|
|
||||||
sensor::Sensor *luminance_level_{nullptr};
|
|
||||||
#endif
|
|
||||||
#ifdef USE_TEXT_SENSOR
|
#ifdef USE_TEXT_SENSOR
|
||||||
text_sensor::TextSensor *serial_{nullptr};
|
text_sensor::TextSensor *serial_{nullptr};
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue