I’ve created a script which gets washer state and consumption and convert it to TTS.
Then at my alexa app I’ve created a routine “Alexa, is the washer running?” which calls this script
Here it is :
washer_state:
alias: WASHER STATE
sequence:
- service: notify.alexa_media_attic
data:
data:
type: tts
message: 'The Washer is currently {{ states("sensor.washer_state") }}.
This month the washing machine has consume {{ states("sensor.snf_washer_energy_total")
}} kWh .'
mode: single
icon: hass:washing-machine
My question is if it would be possible to have the answer announced from the alexa device which triggered the question?
E.g. if I ask at bedroom then get answer at bedroom.
Because currently I always get the answer at attic.
I noticed that media_player exposed at attributes last_called: true
After a bit of searching I found the following:
U can create a sensor of last called device and then use this sensor as target.
Exactly what I was looking for!
So here is how my code looks like now after implementing the above
washer_state:
alias: WASHER STATE
sequence:
- delay:
seconds: 0.5
- service: alexa_media.update_last_called
- delay:
seconds: 3
- service: notify.alexa_media
data_template:
target: '{{ states.sensor.last_alexa.state }}'
data:
type: tts
message: 'The Washer is currently {{ states("sensor.washer_state") }}.
This month the washing machine has consume {{ states("sensor.snf_washer_energy_total")
}} kWh .'
mode: single
icon: hass:washing-machine
I increased the delay after first service call as HA didn’t have the time to update the sensor.
Tested several times and with 3’’ it works perfect!
Problem solved