Why did this automation run while media_player.kodi is in the state ‘idle’
am I doing something wrong with the several conditions (specifically the NOT condition)?
- alias: 'Lights on as the sun gets dimmer and Kodi is playing'
trigger:
platform: numeric_state
entity_id: sensor.woonkamer_lux
below: 3
condition:
condition: and
conditions:
- condition: time
before: '22:30:00'
- condition: or
conditions:
- condition: state
entity_id: media_player.kodi
state: 'paused'
- condition: state
entity_id: media_player.kodi
state: 'playing'
- condition: not
conditions:
- condition: state
entity_id: light.hue_color_1_voor
state: 'on'
The recent addition is this:
- condition: not
conditions:
- condition: state
entity_id: light.hue_color_1_voor
state: 'on'
but as far as I know I’m doing that correctly.
It seems it’s not performing the AND for all those conditions and triggers just based on the light.hue_color_1_voor being off.
I have it fully in yaml. When I click traces through the UI it says nothing found. I guess I could port it to the new automation ui part and then do traces, right?
Until now I have all my automations in yaml. Been with Home Assistant for about 7 years now
@finity it ran while:
yes it was before 22:30
no kodi was no in playing or paused because it was in state “idle”
yes the lihgt was off.
So I as I understand it shouldn’t have ran because not all conditions were met.
But to me it seems like it’s not doing the AND properly for the NOT condition. And it’s treating that as an OR.
You don’t need to do that. just add an “id:” line to the automation config and you can then get traces
And just to be sure your indenting isn’t an issue (but it looks right to me) you can just move the “not” above the “or”.
- alias: 'Lights on as the sun gets dimmer and Kodi is playing'
id: some_random_string_here
trigger:
platform: numeric_state
entity_id: sensor.woonkamer_lux
below: 3
condition:
condition: and
conditions:
- condition: time
before: '22:30:00'
- condition: not
conditions:
- condition: state
entity_id: light.hue_color_1_voor
state: 'on'
- condition: or
conditions:
- condition: state
entity_id: media_player.kodi
state: 'paused'
- condition: state
entity_id: media_player.kodi
state: 'playing'
Thanks everyone for your suggestions.
It seems moving the NOT above OR has done the trick.
Since that change I didn’t see any wrong triggers happening anymore.
I’ll monitor a few more days before selecting the “solution” answer.
At the time it actually needed to run (last night) it ran correctly however what I find interesting is that the traces info shows FALSE for the NOT condition.
I would expect it would show TRUE.
The wanted state should be “off” (which was the case when the automation ran well last night).
Perhaps the traces part isn’t coping well with NOT conditions?
Ah yes sorry for the confusion.
I have 2 quite similar automations. One is for when kodi is playing or paused and the other for when kodi is idle.
Yesterday the one triggered where kodi is not playing (which was expected behavior) so that’s the tracing you see.
The other one didn’t run at all (which is also expected behavior).
Reason for the NOT ‘on’ checking is because I noticed occasionally the light is in the status “unavailable”. So just checking for OFF is not enough.
Now I could also check for off AND unavailable but I thought perhaps there are even more statuses I don’t know about so that’s why I wanted to specifically check for NOT being on.