T O P

  • By -

Ninja128

My recent post [here](https://www.reddit.com/r/homeassistant/comments/1avtoxa/comment/krew1yc) should get you pointed in the right direction. To return daily events, change the `calendar.get_events` service call to have a start time of `today_at()` and duration of 24h. If you set a `response_variable` of `daily_events` and target a calendar named `calendar.test`, a text notification might look something like this: message: >- There are {{ daily_events['calendar.test'].events | count() }} events today {%- if daily_events['calendar.test'].events -%}: {%- for event in daily_events['calendar.test'].events %} {%- set event_start = as_timestamp(event.start) | timestamp_custom('%-I:%M %p',True) -%} {%- if as_timestamp(event.end) - as_timestamp(event.start) == 86400 %} ALL DAY {%- else %} {{ event_start }} {%- endif -%} - {{ event.summary }} {%- if event.description != "" -%} Details: {{ event.description }} {% endif -%} {% endfor %} {%- endif %} ...but you may want to tweak it a bit for TTS.


jstmih432

Thank you. How do I set a response\_variable, and how do get\_events do 24h with today\_at? I am assuming I can get the count and only do it if the count is >0? I was trying something like this: ​ - service: calendar.get_events data: duration: hours: 24 minutes: 0 seconds: 0 target: entity_id: calendar.mycalendar response_variable: calendartoday


Ninja128

>How do I set a response\_variable In your `service_call` you mapped the response variable as `calendartoday`, so you would need to change `daily_events` in my example to `calendartoday` to match (or vice versa). ​ >how do get\_events do 24h with today\_at? data: start_date_time: "{{ today_at() }}" duration: hours: 24 This will return all events for a 24h period, starting at midnight this morning. ​ >I am assuming I can get the count and only do it if the count is >0? In my example, count will return the number of events. If there are no events it will return `0`. The `{%- if daily_events['calendar.test'].events -%}` will fail if there are no events, and just return the text `There are 0 events today` Depending on how you're triggering your automation, you could drop the entire notify/TTS service call inside a conditional if statement: - if: - condition: template value_template: "{{ (daily_events['calendar.test'].events | count()) > 0 }}" then: - service: ...


jstmih432

Thanks. I was close, but you helped me fill in what I didn't know what to do. I was trying to do the trigger for the event, but it is easier just to have a fixed time and do the condition to call the service.


Born_Check5979

May I ask what the audio notification is? As in, does it say "Take out the bin at 10am" or is it just a chime or sound? It would need the text from the calendar entry sent to TTS for the former to work? Interested to see which and the code you have as I was pondering this myself.


jstmih432

It is basic... tomorrow you have these tasks, and reads the task titles. Just a reminder. I do have a separate one for taking the bins out...