Hello I would use a state change as the trigger, then in the action use an if to look for an off. That way you could use it to turn on the speakers with the chromecast
I was looking for automtion that turns off the speakers, but I could have the same approach for turning them on.
If I understood correctly, that triger would be active at any state change (from on to off, from off to unavailable, from off to on, from unavailable to off) and then using IF ChromeCast is off it would activate automation even when it changes from unavailable to off. That wouldn't solve the issue, am I missing something?
I want it to triger when changing from on to off only, while ignoring change from unavailble to off.
That is true, there migh be a state change from on to off that you can pick
Oh you are right, didn't know that was available in HA GUI. Thank you, I'll test it out later.
How I keep that sort of thing in a single automation is by using trigger IDs and a service call with a template for said trigger id.
Something like this:
alias: Hallway Motion Light
description: ""
trigger:
- platform: state
entity_id:
- binary_sensor.hallway_motion_occupancy
to: "on"
id: "on"
- platform: state
entity_id:
- binary_sensor.hallway_motion_occupancy
to: "off"
id: "off"
for:
hours: 0
minutes: 1
seconds: 0
condition: []
action:
- service: light.turn_{{ trigger.id }}
data:
transition: 3
target:
entity_id: light.hallway_light_2_2
mode: single
Just specify from: on and to: off in the trigger. You can have both!
I don't know your automation format very well. My automations use a state trigger with from: and to:
Yeah it looks like OP is using the device actions instead of dealing with the entity directly.
You are right, its working fine now. Wasnt aware that from/to was implemented. Thx
homeassistant
Home Assistant is open source home automation that puts local control and privacy first. Powered by a worldwide community of tinkerers and DIY enthusiasts. Perfect to run on a Raspberry Pi or a local server. Available for free at home-assistant.io