I’m using a Shelly Uni and 2 momentary buttons as detached buttons to trigger an automation (such as switch from ‘day’ to ‘night’ scene). I’m struggling to get the yaml to work correctly. This is what I have:
binary_sensor:
- platform: gpio
pin:
number: GPIO12
mode:
input: true
pullup: true
inverted: true
id: button1
on_click:
- switch.template.publish:
id: switch1
state: !lambda |-
if (id(switch1).state) {
return false;
} else {
return true;
}
internal: true
switch:
- platform: template
name: Day/Night Switch
id: switch1
optimistic: true
lambda: return id(switch1).state;
The soft switch shows up correctly in Home Assistant and the behavior is correct. I can turn the switch on and off (and see the correct MQTT messages flowing back and forth)
However, I can’t get the physical button to work. When pressing, I see the button state changing but the template switch state is not changing. I can’t figure out what I’m doing wrong. Any thoughts?