If you use Alexa Media Player there is a last_alexa sensor
and this is probably a whole 'nother can of worms but i realized my example automation wouldn’t make sense without explaining… i use a “virtual light” which was my initial method of connecting my HA/Emulated Hue/and Alexas… i do realize there are other methods of accomplishing this with routines/Alexa Smart Home Skill… but too many of my automations i have use this and have not yet changed alot of them… it involves using an Alexa routine to trigger the “virtual bulb” which HA watches for brightness level changes and HA use that brightness to trigger the needed automation…
############################### FIRETV TURN ON
- alias: FireTV Turn On
id: d75d7630-421d-4ebc-8de7-a7047b77069b
trigger:
- entity_id: sensor.alexa_virtual
platform: state
to: '18'
action:
- service: light.turn_off
entity_id: light.alexa_virtual
- delay: '00:00:01'
- service: media_player.turn_on
data_template:
entity_id: >-
{% if is_state('sensor.last_alexa','media_player.living_room_echo') %}
media_player.fire_tv
{% elif is_state('sensor.last_alexa','media_player.echo_show') %}
media_player.fire_tv
{% elif is_state('sensor.last_alexa','media_player.bedroom_dot') %}
media_player.brian_s_fire_tv_stick
{% elif is_state('sensor.last_alexa','media_player.girls_dot') %}
media_player.girls_fire_tv
{%-endif-%}
- delay:
milliseconds: 500
- service: light.turn_off
entity_id: light.alexa_virtual