foxcris / appdaemon-telegrambot

Simple bot to control your home-assistant
GNU General Public License v3.0
22 stars 11 forks source link

Enhancement: Support Time to destination with waze #8

Closed foxcris closed 3 years ago

foxcris commented 4 years ago

Extracted from https://github.com/foxcris/appdaemon-telegrambot/issues/2

In my setup i define several zones which i use in waze platform , and by input_select i can get the time to destination ,route an etc. so from app - if user send /waze and then present him source and destination option by the input_select and then present him summary of time to destination and route. This could be very useful....

avico78 commented 4 years ago

I think we can achieve this by following approach:

1.user [should] define zones in HA, (maybe even we can take more zones from app.yaml)

- name: My Work
  latitude: !secret avi_work_latitude
  longitude: !secret avi_work_longitude 
  radius: 150
  icon: mdi:factory

- name: My Home
  latitude: !secret home_work_latitude
  longitude: !secret home_work_longitude 
  radius: 150
  icon: mdi:factory

In application user click on /waze app send a "FROM address" to user by a list of predefined zones we have in HA - << if somehow we can get user current latitude and longitude to get user current place it would be great - I think the easiet way is to get it from HA see mobile app sensor usually looks as _geocoded_location sensor

User choose the zone for "FROM" App sent destination options with list of zone define in HA

Next,app send some message for "wait...calculating route and time of arrival " and return message with attributes by executing service: homeassistant.update_entity

see HA setup: https://community.home-assistant.io/t/waze-travel-time-update/50955/299

avico78 commented 4 years ago

anyone can explain how this feature can be added to the app?

foxcris commented 4 years ago

perhaps its the best idea to just search all person entity for the current gps location. These can then be combined the configured zones in the home-assistant instance. To calculate the traveltime its then probabliy best to not use any home-assitant function and use a direct api call to waze/google/... The current sensor handling of home-assitant is not really flexible.

foxcris commented 4 years ago

I justed pushed a new uptate to the master branch. You can now sent a location message from telegram to the TelegramBot. The location is extracted and for each defined zone in home-assistant the travel time is computed from the sent location to the defined zones. I think this workflow is much more intutive and without additonal request to the user. Of course we are always computing the travel time to all zone and not only the one the user is interessted.

For the travel time computation WazeRouteCalculator is used.

@avico78 : Please give it a try.