Hello everyone,
My use case:
I am using https://distancematrix.ai/ to get an ETA home/work for my wife, with transport mode = public transports. Works great, and very useful.
How I am doing it:
Usin Restful sensors, I am able to query the information I need, format it into minutes, and use it back on the dashboard to display a quick glance value.
sensor:
- platform: rest
name: "Wifey ETA to work"
resource_template: https://api.distancematrix.ai/maps/api/distancematrix/json?key=API_KEY&mode=transit&destinations=WORK_ADDRESS&origins={{ (states('sensor.wifey_phone_geocoded_location') | urlencode) }}
value_template: "{{ ((value_json.rows[0].elements[0].duration.value | int(0)) / 60) | int(0) }}"
scan_interval: 900
- platform: rest
name: "Wifey ETA to home"
resource_template: https://api.distancematrix.ai/maps/api/distancematrix/json?key=API_KEY&mode=transit&destinations=HOME_ADDRESS&origins={{ states('sensor.wifey_phone_geocoded_location') | urlencode }}
value_template: "{{ ((value_json.rows[0].elements[0].duration.value | int(0)) / 60) | int(0) }}"
scan_interval: 900
What is wrong:
The API I am using is limited to 1000 calls a month, and even with scan_interval specified, the sensors are polling too much. And in fact I don’t need the information to be there all the time.
What I would like to achieve:
I could have the information requested from the API once a day in the morning, but when I do need an updated ETA, I want to be able to click the chip and make it refresh the ETA value with an on-demand query.
Fiddled with automation, template sensors, etc but eveytime I am either lacking trigger / action / possibility to return a value / …
How can I do it in your opinion? (open to redesigning the whole thing of course… I think that what I am doing today is a bit dirty anyways).