Text to Speech Notification to Leave for Appointment

The google travel time reports time in minutes (even if it’s over an hour). I then took that time in mins and converted it into seconds (x 60) and subtracted that from the calendar start time.

Did you make sure you changed all of the “calendar.jeremy” to whatever your calendar is named? It looks like it’s not finding your calendar and then using your work as a back-up (as intended in my script)

FYI If you’re on 36.1 there’s a bug where the calendar doesn’t read after the first appointment. https://github.com/home-assistant/home-assistant/issues/5438

Yes I did, all the sensor information displays correctly except for the leaving time

Change the ‘destination:sensor.new_cal_location’ to just 'destination: sensor.cal_location. I had created the extra sensor to handle the if statement when it finds no address. But if it’s not working correctly (and I can’t troubleshoot until I get the calendar component working again) then just bypass that part.

 - platform: google_travel_time
   api_key: YOUR_GOOGLE_API_HERE
   origin: zone.home
   destination: sensor.cal_location

Thanks a lot for this awesome script! Works great.

The only problem I have is when there is no future appointment collected (for some reason there’s no next appointment collected/loaded after the first appointment), is that it seems to show a random map and streetview somewhere in Italy… But that might be a bug/default setting on the Google API side…it’s just a random location…

At the moment my Sonos_Restore is not working though (or it might be caused by the Sonos_Snapshot not working), so unfortunately it doesn’t resume playing music afterwards. But that should be a minor and not too hard fix…

Yes, there’s a problem with the calendar component that doesn’t retrieve calendar items after the first one of the day. I saw someone had reported it on github so hopefully it should be fixed soon in an upcoming release. Seemed to have broken with 0.36.1

As for the Sonos restoring…I did see someone came up with a better version of the time delay script. I haven’t tried it yet, since it was resuming fine for me but you may want to give that a try…

@Bob_NL Check out
https://www.fieldstonsoftware.com/software/gsyncit4/download.shtml
to sync your exchange calendar with your gmail calendar.
It’s for free for up to 1 exchange to 1 gmail and does the job pretty good IMHO.

Hope this helps!

@Jer78 Very nice project! Gonna play with it myself. Bookmarked!

@molano thanks but doesn’t seem to connect. I hope I have time to dive into this next weekend.

@Bob_NL What do you mean by doesn’t connect? It’s just an “Add-on” to your MS Outlook that just reads the client (= Outlook) calendar(s).
Install, go to Outlook, plugins/add-ons, configure.

Using the “Outlook 2013 Desktop App” now, will try alternate Outlook application later and try again

Hi.

I’m trying to make HASS inform me when i’m about to leave for work.
I have set up a google travel sensor, with the arrival time 08:00:00.

Now i’m trying to make an template which check wether it is time to leave my house.

In my head I got something like this

{{ sensor.google_travel.attributes.arrival_time - ((sensor.google_travel.state | int) * 60) == now() }}

But no matter what i’m trying to do, I can’t get it to work. And thinking it is due to arrival_time isn’t a timestamp.

Anyone got an idea what I can do?

Yes, it needs to be a time stamp. It’s in my post above.

Hi… it is certainly a creative work and very much functionally useful going beyond the technical interest.

I shall try it out during this week and get back.

Appreciate your thoughfulness and initial effort put to get this working.

@Jer78 Thanks for posting your config. I’ve been trying to do the same thing, but I wanted to try and use at from the time trigger. So, instead of the following (I’m using your config here as an example):

- alias: 'Announce Calendar Leave time'
  trigger:
    platform: time
    minutes: '/1'
    seconds: 0
  condition:
    condition: and
    conditions:
      - condition: template
        value_template: '{{ states.sensor.sys_time.state == states.sensor.calc_leave_time.state }}'

I would rather like to do the following:

- alias: 'Announce Calendar Leave time'
  trigger:
    platform: time
    at: states.sensor.calc_leave_time.state

That doesn’t seem to work though.

In my own configuration I have the following sensor which is using the google_travel_time sensor called ‘sensor.my_sensor’:

- platform: template
  sensors:
    leave_for_my_sensor:
      value_template: "{{ strptime(states.sensor.my_sensor.attributes.arrival_time, '%H:%M:%S') - strptime(states.sensor.my_sensor.state, '%M') }}"
      friendly_name: My sensor
      unit_of_measurement: time

Its state is e.g. 9 and its attributes.arrival_time is set to '08:10:00', so as a result I would like to get '08:01:00', which is working and I do get that as a result. The problem I’m having is using this value in an automation.

In my automation I’m trying to use it like the following:

trigger:
  - platform: time
    at: sensor.leave_for_my_sensor

That results in the following error:

Invalid config for [automation]: Invalid time specified: sensor.leave_for_my_sensor for dictionary value @ data['trigger'][0]['at']. Got None

I’ve also tried to use it like this (doesn’t work either):

trigger:
  - platform: time
    at: '{{ sensor.leave_for_my_sensor }}'

So, I was wondering why you’re using it like this instead of using at for instance and also if someone here could point me in the right direction to use it in combination with at.

That would not work as you set the platform as time but you use a state for your at trigger.
I would probably change this into a sensors that tracks the minutes before you need to leave. When this drops below a set number (e.g. 5 min) then your automation would trigger

I’m using unit_of_measurement: time in the sensor, so shouldn’t the state be a time object? I’ve only been using Home Assistant for a couple of weeks, so I’m not completely sure if thats correct (probably not, since it’s not working).

Anyway, like I said… I’m new to Home Assistant, so which platform sensor would that be? I’m guessing you would use numeric_state since you mentioned below. Is that correct?

correct, numeric_state is what you would need to use

HI,

because Google is soon to limit its api call further, I’ve tried to rewrite my sensors into a package, enabling some dynamic sensor api calling vs the fixed and permanent sensor settings.

Ive run into some surprises (can have the destination and origin in a sensor, and select these via input_select), cant have that with the Mode…
zones won’t be accepted, same with device_trackers. While they are accepted in the regular Google Traveltime format… Strange it is.

Also, I’d like to have several preset options, but also have the input_select select the state of an input_text, for those destinations not prescribed, Could this be made possible?

For the input_select.text’s id like it to show some preformatted pattern, like [City, Country]. Right now my settings are not working, so how could i change that please?

Please have a look with me below:

##########################################################################################
# Package Google Traveltime
# only feed api with calls while necessary/desired to mitigate api call restrictions
# MtHvdB 07072018
##########################################################################################

homeassistant:
  customize:
    sensor.travel_destination:
      templates:
        icon: >
          if (entities['input_select.travel_mode'].state === 'bicycling') return 'mdi:bike';
          if (entities['input_select.travel_mode'].state === 'driving') return 'mdi:car';
          if (entities['input_select.travel_mode'].state === 'walking') return 'mdi:transit-transfer';
          if (entities['input_select.travel_mode'].state === 'transit') return 'mdi:train';
          return 'mdi:bus';
    sensor.select_travel_destination:
      icon: mdi:login
    sensor.select_travel_origin:
      icon: mdi:logout
    sensor.select_travel_mode:
      icon: mdi:transit-transfer
    input_select.travel_mode:
      templates:
        icon: >
          if (state === 'bicycling') return 'mdi:bike';
          if (state === 'driving') return 'mdi:car';
          if (state === 'walking') return 'mdi:transit-transfer';
          if (state === 'transit') return 'mdi:train';
          return 'mdi:bus';
    sensor.distance_selected_destination:
      icon: mdi:map-marker-distance
      friendly_name: Distance
    sensor.duration_selected_destination:
      icon: mdi:timer
      friendly_name: Duration
    sensor.duration_in_traffic_selected_destination:
      icon: mdi:traffic-light
      friendly_name: In traffic

sensor:
  - platform: google_travel_time
    api_key: !secret google_travel
    mode: sensor.select_travel_mode
    departure_time: now
    name: Travel destination
    origin: sensor.select_travel_origin
    destination: sensor.select_travel_destination

  - platform: template
    sensors:
      select_travel_destination:
        value_template: '{{states.input_select.travel_destination.state}}'
      select_travel_origin:
        value_template: '{{states.input_select.travel_origin.state}}'
      select_travel_mode:
        value_template: '{{states.input_select.travel_mode.state}}'
      distance_selected_destination:
        value_template: '{{states.sensor.travel_destination.attributes.distance}}'
      duration_selected_destination:
        value_template: '{{states.sensor.travel_destination.attributes.duration}}'
      duration_in_traffic_selected_destination:
        value_template: '{{states.sensor.travel_destination.attributes.duration_in_traffic}}'

input_text:
  travel_destination:
    icon: mdi:login
    name: Travel destination
    pattern: [City, Country]
  
  travel_origin:
    icon: mdi:logout
    name: Travel origin
    pattern: [City, Country]
    
input_select:
  travel_destination:
    icon: mdi:login
    name: Travel destination
    options:
      - Select
      - Paris, France
      - Amsterdam, Netherlands
      - Eindhoven, Netherlands
      - Utrecht, Netherlands
      - Brussels, Belgium
      - Berlin, Germany
      - Bayreuth, Germany
      - '{{states.input_text.travel_destination.state}}'
      - zone.home
      - device.tracker.iphone
      - device.tracker.telefoon
    initial: Select

  travel_origin:
    icon: mdi:logout
    name: Travel origin
    options:
      - Select
      - Paris, France
      - Amsterdam, Netherlands
      - Eindhoven, Netherlands
      - Utrecht, Netherlands
      - Brussels, Belgium
      - Berlin, Germany
      - Bayreuth, Germany
      - '{{states.input_text.travel_origin.state}}'
      - zone.home
      - device_tracker.iphone
      - device_tracker.telefoon
    initial: Select

  travel_mode:
    icon: mdi:bike
    name: Travel mode
    options:
      - driving
      - bicycling
      - walking
      - transit
    initial: bicycling

group:
  travel_destination:
    name: Travel destination
    icon: mdi:transit-transfer
    entities:
      - input_select.travel_origin
      - input_text.travel_origin
      - input_select.travel_destination
      - input_text.travel_destination
      - input_select.travel_mode
      - sensor.travel_destination
      - sensor.distance_selected_destination
      - sensor.duration_selected_destination
      - sensor.duration_in_traffic_selected_destination


thanks,
Marius

2 Likes

sorry, @Jer78 but your picture is deleted. can you post it again?

Hello I was happy to find this thread when I came up with the exact same idea.
I especially liked the camera section for displaying nice images.

Hower they don’t appear in the frontend at all. When I click on them on the /dev-state page I don’t see a image either. The state is “idle”.
The log file is empty, I don’t see any errors.

For reference, here is my config: https://github.com/eifinger/homeassistant-config

Does anybody know what is going on?