1
0
mirror of https://github.com/esphome/esphome.git synced 2025-10-29 22:24:26 +00:00

Allow id() syntax for custom code (#621)

* Allow id() syntax for custom code

* Lint
This commit is contained in:
Otto Winter
2019-06-07 14:26:17 +02:00
committed by GitHub
parent 726b0e73d9
commit 4fe0c95ccb
4 changed files with 20 additions and 3 deletions

View File

@@ -3,7 +3,12 @@
class CustomSensor : public Component, public Sensor {
public:
void loop() override { publish_state(42.0); }
void loop() override {
// Test id() helper
float value = id(my_sensor).state;
id(my_global_string) = "Hello World";
publish_state(42.0);
}
};
class CustomTextSensor : public Component, public TextSensor {