this post was submitted on 03 Jul 2024
11 points (100.0% liked)

homeassistant

12129 readers
10 users here now

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

founded 2 years ago
MODERATORS
 

Hey guys,

I made an automation that powers off my bluetooth speaker (using IR blaster) when ChromeCast is powered off for more than 10 s. Automation is working fine, but sometimes ChromeCast changes state from OFF to Unavailable and back to OFF in just a few seconds. I have no idea why is that happening, but it triggers automation and turns ON the speaker (it is the same IR button for ON and OFF) and gets it out of sync.

What condition or trigger should I use to make it work only when ChromeCast state changes from ON to OFF and ignores Unavailable to OFF?

There is my automation:


alias: Turn off JBL
description: if CC is off for 10 sec
trigger:
  - platform: device
    type: turned_off
    device_id: bc1049ea43a53092952d364749c3fb4c
    entity_id: ae0ea35649746ed5cea16f8d6ca54dd3
    domain: remote
    for:
      hours: 0
      minutes: 0
      seconds: 10
condition: []
action:
  - service: remote.send_command
    metadata: {}
    data:
      num_repeats: 1
      delay_secs: 0.4
      hold_secs: 0
      device: jbl
      command: "off"
    target:
      device_id: 4f1f3a13324e03646ff6b03aed27f2fe
mode: single

thanks in advance

you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 1 points 4 months ago (1 children)

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

[–] [email protected] 1 points 4 months ago (1 children)

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.

[–] [email protected] 1 points 4 months ago (1 children)

That is true, there migh be a state change from on to off that you can pick

[–] [email protected] 2 points 4 months ago

Oh you are right, didn't know that was available in HA GUI. Thank you, I'll test it out later.