Null state
sEdsKi opened this issue · comments
This automation works great
alias: AAA - Discord
description: ""
trigger:
- platform: state
entity_id:
- sensor.discord_user_***
attribute: voice_channel
to: General
condition: []
action:
- device_id: ***
domain: cover
entity_id: cover.guest_blind
type: set_position
position: 0
mode: single
The issue appears to be with the null state of the attribute. This automation won't trigger when leaving a channel and the state of voice_channel reverts to null.
alias: AAA - Discord
description: ""
trigger:
- platform: state
entity_id:
- sensor.discord_user_***
attribute: voice_channel
to: null
condition: []
action:
- device_id: ***
domain: cover
entity_id: cover.guest_blind
type: set_position
position: 100
mode: single
Try using to: "null"
insterad of to: null
Try using
to: "null"
insterad ofto: null
It still does not work
I have the automation working for 1 specific channel name, but by getting the to: null
state to work then the automation will work for any channel I join.
I am no home assistant expert, however, my intuition is telling me that the null state of the attributes is being handled by HA differently than expected and null
should be changed to some other value such as none
I know you could do it in an automation trigger but I like to make template binary sensors and then use the state change of the binary sensor to trigger the automation, you could make a binary sensor using the following template.
{{states.sensor.discord_user_##############.attributes.voice_channel|default('disconnected',true) != 'disconnected'}}
this will set the binary sensor to on when voice channel has a value and off when voice channel is 'null'
you could then have one automation.
alias: AAA - Discord
description: ""
mode: single
trigger:
- platform: state
entity_id:
- binary_sensor.discord_voice_channel
variables:
position: >-
{% if trigger.to_state.state == 'on'%}
100
{% else %}
0
{%endif%}
action:
- device_id: ***
domain: cover
entity_id: cover.guest_blind
type: set_position
position: "{{position}}"
the formating of the yaml got ruined but you get the gist
Closing a stale. Also you no longer need template sensors with version 6.0.0, that should help a little.