I’m trying to use global variables for a binary template sensor.
The declaration throws the error:
[globals] is an invalid option for [binary_sensor.template]. Please check the indentation.
When I try to set a value, I get the following error:
Unable to find action with the name 'globals.set'.
Here is the relevant code:
binary_sensor:
- platform: template
id: "${button_id}_action"
lambda: |-
return id(${button_id}).state;
globals:
- id: red
type: float
on_click:
- globals.set:
- id: red
value: '1.0'
- min_length: 50ms
max_length: 350ms
then:
- if:
condition:
light.is_on: "${light_id}"
then:
light.turn_off: "${light_id}"
else:
I followed the documentation https://esphome.io/guides/automations.html#bonus-2-global-variables and https://esphome.io/guides/automations.html#globals-set-action
What am I missing?