Hi, I would like to turn on/off switch with MQTT but in automation. Main thought is → when I leave my house, script for LED strip turn off and also main light in my room will turn off. With script it is easy, but how can turn off switch from automation?
my code:
- alias: Arrive at home
trigger:
platform: state
entity_id: device_tracker.timco #my iPhone which indicate if I am away from home
from: 'home'
to: 'not_home'
action:
- service: script.ledstripoff
- service: switch.main_light # ????
There are also switch.turn_on and switch.toggle services.
If it was a light entity you would use the light.turn_off service.
See the note on the service tool here for how to discover more services:
There is also the homeassistant.turn_off service which will work for any entity that can be turned on or off. Why use the light and switch services instead of the home assistant service?
IDK