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:
@@ -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 {
|
||||
|
@@ -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: []
|
||||
|
Reference in New Issue
Block a user