home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
73.25k stars 30.59k forks source link

google_travel _time options: mode can't take the state from an " input_select" or sensor as argument #11606

Closed PetterSjo closed 5 years ago

PetterSjo commented 6 years ago

Make sure you are running the latest version of Home Assistant before reporting an issue.

You should only file an issue if you found a bug. Feature and enhancement requests should go in the Feature Requests section of our community forum:

Home Assistant release (hass --version): 0.60.1

Python release (python3 --version): Python 3.6.3

Component/platform: sensor.google_travel_time

Description of problem: options -> mode can't take the state from an " input_select" or sensor as argument the same way as it's possible for options-->arrival_time

Expected: Expect to be able to chose mode using a sensor or input_select object

Problem-relevant configuration.yaml entries and steps to reproduce:

# sensors.yaml

  - platform: google_travel_time
    name: input_select_next_appointment
    api_key: !secret google_API_KEY
    origin: device_tracker.petter_android
    destination: sensor.cal_location        
    options: 
      arrival_time: sensor.cal_start_time
      mode: input_select.way_of_travel

# configuration.yaml

input_select:
  way_of_travel:
    name: Way of traveling
    options:
     - transit
     - driving
     - walking
     - bicycling
    icon: mdi:bus

Traceback (if applicable):

2018-01-12 21:43:36 ERROR (MainThread) [homeassistant.config] Invalid config for [sensor.google_travel_time]: value is not allowed for dictionary value @ data['options']['mode']. Got 'input_select.way_of_travel'. (See ?, line ?). Please check the docs at https://home-assistant.io/components/sensor.google_travel_time/

Additional info: Have also tried all to replace "input_select.way_of_travel" with all sorts of sensors but with the same fault. My guess is that is connected to have arguments are read in "google_travel_time.py" but don't have the programming skills to test my hypothesis.

https://github.com/home-assistant/home-assistant/blob/master/homeassistant/components/sensor/google_travel_time.py

`VOID = ['tolls', 'highways', 'ferries', 'indoor']
TRANSIT_PREFS = ['less_walking', 'fewer_transfers']
TRANSPORT_TYPE = ['bus', 'subway', 'train', 'tram', 'rail']
TRAVEL_MODE = ['driving', 'walking', 'bicycling', 'transit']
TRAVEL_MODEL = ['best_guess', 'pessimistic', 'optimistic']
UNITS = ['metric', 'imperial']

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Required(CONF_API_KEY): cv.string,
    vol.Required(CONF_DESTINATION): cv.string,
    vol.Required(CONF_ORIGIN): cv.string,
    vol.Optional(CONF_NAME): cv.string,
    vol.Optional(CONF_TRAVEL_MODE): vol.In(TRAVEL_MODE),
    vol.Optional(CONF_OPTIONS, default={CONF_MODE: 'driving'}): vol.All(
        dict, vol.Schema({
            vol.Optional(CONF_MODE, default='driving'): vol.In(TRAVEL_MODE),
            vol.Optional('language'): vol.In(ALL_LANGUAGES),
            vol.Optional('avoid'): vol.In(AVOID),
            vol.Optional('units'): vol.In(UNITS),
            vol.Exclusive('arrival_time', 'time'): cv.string,
            vol.Exclusive('departure_time', 'time'): cv.string,
            vol.Optional('traffic_model'): vol.In(TRAVEL_MODEL),
            vol.Optional('transit_mode'): vol.In(TRANSPORT_TYPE),
            vol.Optional('transit_routing_preference'): vol.In(TRANSIT_PREFS)
        }))
})`
balloobbot commented 6 years ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.

Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment :+1:

balloobbot commented 6 years ago

This issue will be auto-closed because there hasn't been any activity for a few months. Feel free to open a new one if you still experience this problem 👍

PetterSjo commented 6 years ago

A similar problem was solved for waze in #14714

reevery commented 6 years ago

I can confirm this is still the case in 0.75.3.

Please can we change the title to reflect all options, not just mode?

My use case: I look for the time to my next appointment (in a calendar), and I have a template sensor to pull mode and arrival time from the calendar description. I can set the arrival time using a sensor (which actually looks like it just posts the string), but not the mode.

I'm also wondering if it is possible to allow using template values for the options, too, as it would save me having to define the sensors.

balloobbot commented 6 years ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.

Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment :+1:

balloobbot commented 5 years ago

This issue will be auto-closed because there hasn't been any activity for a few months. Feel free to open a new one if you still experience this problem 👍