I have spent hours trying to find why the global variable and the binary_sensor do not update. I need a ‘fresh’ set of eyes. Would you please review the code?
The code compiles without errors.
globals:
- id: alarm_status_var
type: bool
restore_value: no
initial_value: 'false'
mqtt:
broker: XXXXXXX
username: 'myusername'
password: 'mypass'
on_message:
- topic: some/topic/alarm_status
payload: 'ON'
then:
- logger.log: 'Alarm armed'
- globals.set:
id: alarm_status_var
value: 'true'
- lambda: !lambda 'id(alarm_status).publish_state(true);'
- logger.log: 'global var to true'
- topic: some/topic/alarm_status
payload: 'OFF'
then:
- logger.log: 'Alarm disarmed'
- globals.set:
id: alarm_status_var
value: 'false'
- lambda: !lambda 'id(alarm_status).publish_state(false);'
- logger.log: 'global var to false'
binary_sensor:
- platform: template
name: 'Alarm Status'
id: 'alarm_status'
lambda: !lambda 'return alarm_status_var;'
device_class: lock