First of all, thanks for your code @lonebaggie!
Sadly I can’t have it working, no matter what, changing the speak list item doesn’t output audio…
I found some discrepancies between the code on the first post and the GH repo, there are also some error reported by VSC (even if I can run the server anyway) that perhaps can influence the result.
I’m also not completely sure if I need to load some other stuff to have it working other than the yaml in the first post.
That’s my actual configuration:
group:
echos:
name: Echo_List
entities:
- media_player.echo_flex_sala2
- media_player.echo_flex_suite
- media_player.echo_dot_coz
- media_player.echo_show_sala1
- media_player.fire_tv_suite
- media_player.fire_tv_qtlor
- media_player.fire_tv_qtcam
sensor:
- platform: template
sensors:
last_alexa:
value_template: >
{{ expand(states.group.echos) | selectattr('attributes.last_called','eq',True) | map(attribute='entity_id') | first }}
light:
- platform: template
lights:
alexa_virtual:
friendly_name: "Alexa Dummy Light"
turn_on:
turn_off:
set_level:
input_select:
entity_list:
name: Entity List
options:
- sensor.suite2_am2301_temperature
speak_list:
name: Speak List
options:
- do not use
- The current time is (tt)
- The current date is (td)
- The current temperature of (e00f) is (e00s)
Please note VSC is returning a non blocking error on light template turn_on
, turn_off
and set_level
(Incorrect type. Expected “object”.)
Automations:
- alias: Item Select to speak
description: Trigger Alexa from Item Select
trigger:
entity_id: input_select.speak_list
platform: state
variables:
opt: >
{% set sp = states.input_select.speak_list.state %}
{% set no = sp.find("(c")+2 %}
{{sp[no:no+2]|int}}
condition:
- condition: template
value_template: '{{states.input_select.speak_list.state != "do not use" }}'
action:
- service: >
{% set name = states('sensor.last_alexa').split('.') %}
notify.alexa_media_{{name[-1]}}
data_template:
data:
type: tts
Please note the service_template
will return a non blocking error on VSC (String does not match the pattern of “DEPRECATED^” because service_template:
must be replaced with service:
since 0.115) and is also not present on GH anymore, I copied the one in the first post hoping is fine but I also tested another one called Alexa Speak
on your GH.
Then the second automation:
- alias: Dummy light to input select
description: Trigger input select from dummy light
trigger:
entity_id: light.alexa_virtual
platform: state
from: 'off'
to: 'on'
action:
- service: input_select.select_option
data_template:
entity_id: input_select.speak_list
option: >
{% set slist = state_attr('input_select.speak_list','options') %}
{% set opt = state_attr('light.alexa_virtual','brightness') %}
{% set opt = (opt | float / 255 * 100+0.5)|int %}
{% if opt|int > slist|length %}
{% set opt = 0 %}
{% endif %}
{{slist[opt]}}
- service: light.turn_off
data:
entity_id: light.alexa_virtual
With this configuration I don’t have any error on logs, it simply doesn’t work, and the automation are not triggered (even if I trigger them manually not output at all).
TTS works with a simpler script:
alexa_tts:
sequence:
- service: script.turn_on
entity_id: script.alexa_set_volume
- delay: "00:00:01"
- service: notify.alexa_media
data_template:
target: "{{ states.sensor.last_alexa.state }}"
message: "Teste de reprodução"
data:
type: "tts"
Do you see something missing/wrong?
Thanks for your time.
EDIT: Using the yaml from the second post I can have it working.
So what should I use since you stated to use just the code on the first post?