ESPHome  2022.6.3
teleinfo_sensor.cpp
Go to the documentation of this file.
1 #include "esphome/core/log.h"
2 #include "teleinfo_sensor.h"
3 namespace esphome {
4 namespace teleinfo {
5 
6 static const char *const TAG = "teleinfo_sensor";
7 TeleInfoSensor::TeleInfoSensor(const char *tag) { this->tag = std::string(tag); }
8 void TeleInfoSensor::publish_val(const std::string &val) {
9  auto newval = parse_number<float>(val).value_or(0.0f);
10  publish_state(newval);
11 }
12 void TeleInfoSensor::dump_config() { LOG_SENSOR(" ", "Teleinfo Sensor", this); }
13 } // namespace teleinfo
14 } // namespace esphome
void publish_state(float state)
Publish a new state to the front-end.
Definition: sensor.cpp:70
void publish_val(const std::string &val) override
Definition: a4988.cpp:4
uint32_t val
Definition: datatypes.h:85