1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-02 03:12:20 +01: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 {

View File

@@ -246,6 +246,11 @@ binary_sensor:
- id: custom_binary_sensor
name: Custom Binary Sensor
globals:
- id: my_global_string
type: std::string
initial_value: '""'
remote_receiver:
pin: GPIO12
dump: []