Closed BoKKeR closed 9 months ago
Any suggestion on how and what is needed? I have no insights into if a sensor value could be used? Anyone
I found a way to make it work! This code only works with one bus, in my case I will set it to 999, you can change the bus number in the script
service: tts.speak
target:
entity_id: tts.google_en_com
data:
message: >
{% set departures = state_attr('sensor.sl_departure_sensor',
'departures') | selectattr('line', 'equalto', '999') | list %} {% if
departures %}
{% set next_departure = departures[0] %}
{% set departure_time = next_departure.expected %}
{% set departure_datetime = departure_time %}
{% set now = now().replace(tzinfo=None) %}
{% set minutes_until_departure = int(((departure_datetime - now).total_seconds() // 60)) %}
leaves in {{ minutes_until_departure }} minutes to {{ next_departure.destination }} number 999.
{% else %}
No line 999 bus departures found.
{% endif %}
media_player_entity_id: media_player.dining_room
cache: true
language: en
This is outside of the scope of this project, but I was wondering if anyone managed to get Alexa or other voice assistant to return the data about the upcoming busses using this sensor. I have the sensor and voice assistant exposed to each other. I am just missing the phrase that would activate it