1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-17 10:42:21 +01:00

Clean-up sensor integration (#2275)

This commit is contained in:
Oxan van Leeuwen
2021-09-13 18:58:49 +02:00
committed by GitHub
parent 924df1e7de
commit e6b0a0ca2b
7 changed files with 102 additions and 210 deletions

View File

@@ -11,7 +11,7 @@ class DemoSensor : public sensor::Sensor, public PollingComponent {
public:
void update() override {
float val = random_float();
bool increasing = this->state_class == sensor::STATE_CLASS_TOTAL_INCREASING;
bool increasing = this->get_state_class() == sensor::STATE_CLASS_TOTAL_INCREASING;
if (increasing) {
float base = isnan(this->state) ? 0.0f : this->state;
this->publish_state(base + val * 10);