eoghan
(Eoghan Cunningham)
February 26, 2022, 4:31pm
1
Hi guys
I have a automation setup that when that when HA detects my Emby media player as ether “idle” or “off” to proceed to the next part of the automation however it just seems to stop and not follow on to the next step.
Here is the yaml code snippet of what I mean
condition: and
conditions:
- condition: state
entity_id: media_player.emby_eoghan_s_fire_tv_cube
state: idle
- condition: or
conditions:
- condition: state
entity_id: media_player.emby_eoghan_s_fire_tv_cube
state: 'off'
Here is also the full code to the automation
- id: '1645763271031'
alias: Turn Everything Off
description: ''
trigger:
- platform: device
domain: mqtt
device_id: 071aad0d25a0b1dd8bf30d1ce36cec48
type: action
subtype: single
discovery_id: 0x00124b00239f20fe action_single
- platform: device
domain: mqtt
device_id: 7237e2b8244dfc0ed7f111477ec0e073
type: action
subtype: double_right
discovery_id: 0x54ef4410002a30bc action_double_right
condition: []
action:
- type: turn_off
device_id: b005053c47f796b4686b4cf1ec8c6bfb
entity_id: remote.sony_bravia_tv
domain: remote
- type: turn_off
device_id: c2c8159e2379eb27e09f7833b2c8dc23
entity_id: switch.light_switch
domain: switch
- condition: and
conditions:
- condition: state
entity_id: media_player.emby_eoghan_s_fire_tv_cube
state: idle
- condition: or
conditions:
- condition: state
entity_id: media_player.emby_eoghan_s_fire_tv_cube
state: 'off'
- scene: scene.lights_out
As you can see the “scene: scene.lights_out” part never runs even though emby is in ether a state of “idle” or “off”.
Hopefully someone smarter than me can see where I have went wrong
The way you have set up your conditions they are just and
… neither the and
nor the or
are actually doing anything.
The or
needs to encapsulate both your conditions as follows:
condition: or
conditions:
- condition: state
entity_id: media_player.emby_eoghan_s_fire_tv_cube
state: 'idle'
- condition: state
entity_id: media_player.emby_eoghan_s_fire_tv_cube
state: 'off'
Since it’s a single entity, you can also just declare two acceptable states:
Automation with Single State Condition
id: '1645763271031'
alias: Turn Everything Off
description: ''
trigger:
- platform: device
domain: mqtt
device_id: 071aad0d25a0b1dd8bf30d1ce36cec48
type: action
subtype: single
discovery_id: 0x00124b00239f20fe action_single
- platform: device
domain: mqtt
device_id: 7237e2b8244dfc0ed7f111477ec0e073
type: action
subtype: double_right
discovery_id: 0x54ef4410002a30bc action_double_right
condition: []
action:
- type: turn_off
device_id: b005053c47f796b4686b4cf1ec8c6bfb
entity_id: remote.sony_bravia_tv
domain: remote
- type: turn_off
device_id: c2c8159e2379eb27e09f7833b2c8dc23
entity_id: switch.light_switch
domain: switch
- condition: state
entity_id: media_player.emby_eoghan_s_fire_tv_cube
state:
- off
- idle
- scene: scene.lights_out
1 Like
eoghan
(Eoghan Cunningham)
February 26, 2022, 4:49pm
3
Hi
I just tried that solution and the automation still stops before the scene is triggered
Take a look at Troubleshooting Automations and post your automation trace.
eoghan
(Eoghan Cunningham)
February 26, 2022, 6:17pm
5
Hi
I hope this is the output that you are looking for
https://files.eoghan-net.com/share/kjytZr6C
Yep. So if you look at the info about your condition:
action/2/conditions/0/entity_id/0": [
{
"path": "action/2/conditions/0/entity_id/0",
"timestamp": "2022-02-26T17:59:58.953582+00:00",
"result": {
"result": false,
"state": "unavailable",
"wanted_state": "idle"
}
}
]
You can see that the state of the media player at the time was “unavailable” not “idle” or “off”. This is common with some media_players when they power down or go into a sleep mode. The solution is to add “unavailable” to your list of acceptable states:
id: '1645763271031'
alias: Turn Everything Off
description: ''
trigger:
- platform: device
domain: mqtt
device_id: 071aad0d25a0b1dd8bf30d1ce36cec48
type: action
subtype: single
discovery_id: 0x00124b00239f20fe action_single
- platform: device
domain: mqtt
device_id: 7237e2b8244dfc0ed7f111477ec0e073
type: action
subtype: double_right
discovery_id: 0x54ef4410002a30bc action_double_right
condition: []
action:
- type: turn_off
device_id: b005053c47f796b4686b4cf1ec8c6bfb
entity_id: remote.sony_bravia_tv
domain: remote
- type: turn_off
device_id: c2c8159e2379eb27e09f7833b2c8dc23
entity_id: switch.light_switch
domain: switch
- condition: state
entity_id: media_player.emby_eoghan_s_fire_tv_cube
state:
- off
- idle
- unavailable
- scene: scene.lights_out
mode: single
eoghan
(Eoghan Cunningham)
February 27, 2022, 11:00pm
7
Absolute gent the states array worked perfectly thank you so much i was pulling my hair out for days trying to find a solution but clearly didn’t read up fully on the yaml side of things.
1 Like