1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-02 03:12:20 +01:00

[switch] Add trigger `on_state` (#10108)

This commit is contained in:
Edward Firmo
2025-08-09 13:09:40 +02:00
committed by GitHub
parent ff9ddb9d68
commit 2b9e1ce315
3 changed files with 31 additions and 0 deletions

View File

@@ -9,6 +9,18 @@ switch:
name: "Template Switch"
id: the_switch
optimistic: true
on_state:
- if:
condition:
- lambda: return x;
then:
- logger.log: "Switch turned ON"
else:
- logger.log: "Switch turned OFF"
on_turn_on:
- logger.log: "Switch is now ON"
on_turn_off:
- logger.log: "Switch is now OFF"
esphome:
on_boot: