Improved method for detecting last Alexa device

This commit is contained in:
2023-03-28 19:10:33 -04:00
parent d10489ce43
commit 36a59f54c5
6 changed files with 8 additions and 27 deletions

View File

@ -166,23 +166,4 @@ automation:
mqtt:
sensor:
- name: "Room Presence"
state_topic: "house/presence/current_room"
sensor:
- platform: template
sensors:
alexa_audio:
friendly_name: "Alexa Audio"
value_template: >-
{%- if is_state('sensor.last_alexa', 'media_player.living_room_echo_dot') %}
Living Room Echo Dot
{% elif is_state('sensor.last_alexa', 'media_player.basement_echo_dot') %}
Basement Echo Dot
{% elif is_state('sensor.last_alexa', 'media_player.master_bedroom_echo_dot') %}
Master Bedroom Echo Dot
{% else %}
Living Room Echo Dot
{%- endif %}
last_alexa:
value_template: >
{{ states.media_player | selectattr('attributes.last_called','eq',True) | map(attribute='entity_id') | first }}
state_topic: "house/presence/current_room"