mirror of
https://github.com/home-assistant/core.git
synced 2025-07-18 18:57:06 +00:00
Required config_flow values for here_travel_time (#75026)
This commit is contained in:
parent
f81cdf4bca
commit
95dd9def66
@ -11,6 +11,8 @@ from homeassistant import config_entries
|
|||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_API_KEY,
|
CONF_API_KEY,
|
||||||
CONF_ENTITY_NAMESPACE,
|
CONF_ENTITY_NAMESPACE,
|
||||||
|
CONF_LATITUDE,
|
||||||
|
CONF_LONGITUDE,
|
||||||
CONF_MODE,
|
CONF_MODE,
|
||||||
CONF_NAME,
|
CONF_NAME,
|
||||||
CONF_UNIT_SYSTEM,
|
CONF_UNIT_SYSTEM,
|
||||||
@ -30,6 +32,8 @@ from .const import (
|
|||||||
CONF_ARRIVAL_TIME,
|
CONF_ARRIVAL_TIME,
|
||||||
CONF_DEPARTURE,
|
CONF_DEPARTURE,
|
||||||
CONF_DEPARTURE_TIME,
|
CONF_DEPARTURE_TIME,
|
||||||
|
CONF_DESTINATION,
|
||||||
|
CONF_ORIGIN,
|
||||||
CONF_ROUTE_MODE,
|
CONF_ROUTE_MODE,
|
||||||
CONF_TRAFFIC_MODE,
|
CONF_TRAFFIC_MODE,
|
||||||
DEFAULT_NAME,
|
DEFAULT_NAME,
|
||||||
@ -187,13 +191,25 @@ class HERETravelTimeConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
|||||||
) -> FlowResult:
|
) -> FlowResult:
|
||||||
"""Configure origin by using gps coordinates."""
|
"""Configure origin by using gps coordinates."""
|
||||||
if user_input is not None:
|
if user_input is not None:
|
||||||
self._config[CONF_ORIGIN_LATITUDE] = user_input["origin"]["latitude"]
|
self._config[CONF_ORIGIN_LATITUDE] = user_input[CONF_ORIGIN][CONF_LATITUDE]
|
||||||
self._config[CONF_ORIGIN_LONGITUDE] = user_input["origin"]["longitude"]
|
self._config[CONF_ORIGIN_LONGITUDE] = user_input[CONF_ORIGIN][
|
||||||
|
CONF_LONGITUDE
|
||||||
|
]
|
||||||
return self.async_show_menu(
|
return self.async_show_menu(
|
||||||
step_id="destination_menu",
|
step_id="destination_menu",
|
||||||
menu_options=["destination_coordinates", "destination_entity"],
|
menu_options=["destination_coordinates", "destination_entity"],
|
||||||
)
|
)
|
||||||
schema = vol.Schema({"origin": selector({LocationSelector.selector_type: {}})})
|
schema = vol.Schema(
|
||||||
|
{
|
||||||
|
vol.Required(
|
||||||
|
CONF_ORIGIN,
|
||||||
|
default={
|
||||||
|
CONF_LATITUDE: self.hass.config.latitude,
|
||||||
|
CONF_LONGITUDE: self.hass.config.longitude,
|
||||||
|
},
|
||||||
|
): LocationSelector()
|
||||||
|
}
|
||||||
|
)
|
||||||
return self.async_show_form(step_id="origin_coordinates", data_schema=schema)
|
return self.async_show_form(step_id="origin_coordinates", data_schema=schema)
|
||||||
|
|
||||||
async def async_step_origin_entity(
|
async def async_step_origin_entity(
|
||||||
@ -206,9 +222,7 @@ class HERETravelTimeConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
|||||||
step_id="destination_menu",
|
step_id="destination_menu",
|
||||||
menu_options=["destination_coordinates", "destination_entity"],
|
menu_options=["destination_coordinates", "destination_entity"],
|
||||||
)
|
)
|
||||||
schema = vol.Schema(
|
schema = vol.Schema({vol.Required(CONF_ORIGIN_ENTITY_ID): EntitySelector()})
|
||||||
{CONF_ORIGIN_ENTITY_ID: selector({EntitySelector.selector_type: {}})}
|
|
||||||
)
|
|
||||||
return self.async_show_form(step_id="origin_entity", data_schema=schema)
|
return self.async_show_form(step_id="origin_entity", data_schema=schema)
|
||||||
|
|
||||||
async def async_step_destination_coordinates(
|
async def async_step_destination_coordinates(
|
||||||
@ -217,11 +231,11 @@ class HERETravelTimeConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
|||||||
) -> FlowResult:
|
) -> FlowResult:
|
||||||
"""Configure destination by using gps coordinates."""
|
"""Configure destination by using gps coordinates."""
|
||||||
if user_input is not None:
|
if user_input is not None:
|
||||||
self._config[CONF_DESTINATION_LATITUDE] = user_input["destination"][
|
self._config[CONF_DESTINATION_LATITUDE] = user_input[CONF_DESTINATION][
|
||||||
"latitude"
|
CONF_LATITUDE
|
||||||
]
|
]
|
||||||
self._config[CONF_DESTINATION_LONGITUDE] = user_input["destination"][
|
self._config[CONF_DESTINATION_LONGITUDE] = user_input[CONF_DESTINATION][
|
||||||
"longitude"
|
CONF_LONGITUDE
|
||||||
]
|
]
|
||||||
return self.async_create_entry(
|
return self.async_create_entry(
|
||||||
title=self._config[CONF_NAME],
|
title=self._config[CONF_NAME],
|
||||||
@ -229,7 +243,15 @@ class HERETravelTimeConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
|||||||
options=default_options(self.hass),
|
options=default_options(self.hass),
|
||||||
)
|
)
|
||||||
schema = vol.Schema(
|
schema = vol.Schema(
|
||||||
{"destination": selector({LocationSelector.selector_type: {}})}
|
{
|
||||||
|
vol.Required(
|
||||||
|
CONF_DESTINATION,
|
||||||
|
default={
|
||||||
|
CONF_LATITUDE: self.hass.config.latitude,
|
||||||
|
CONF_LONGITUDE: self.hass.config.longitude,
|
||||||
|
},
|
||||||
|
): LocationSelector()
|
||||||
|
}
|
||||||
)
|
)
|
||||||
return self.async_show_form(
|
return self.async_show_form(
|
||||||
step_id="destination_coordinates", data_schema=schema
|
step_id="destination_coordinates", data_schema=schema
|
||||||
@ -250,7 +272,7 @@ class HERETravelTimeConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
|||||||
options=default_options(self.hass),
|
options=default_options(self.hass),
|
||||||
)
|
)
|
||||||
schema = vol.Schema(
|
schema = vol.Schema(
|
||||||
{CONF_DESTINATION_ENTITY_ID: selector({EntitySelector.selector_type: {}})}
|
{vol.Required(CONF_DESTINATION_ENTITY_ID): EntitySelector()}
|
||||||
)
|
)
|
||||||
return self.async_show_form(step_id="destination_entity", data_schema=schema)
|
return self.async_show_form(step_id="destination_entity", data_schema=schema)
|
||||||
|
|
||||||
|
@ -9,9 +9,11 @@ DOMAIN = "here_travel_time"
|
|||||||
DEFAULT_SCAN_INTERVAL = 300
|
DEFAULT_SCAN_INTERVAL = 300
|
||||||
|
|
||||||
|
|
||||||
|
CONF_DESTINATION = "destination"
|
||||||
CONF_DESTINATION_LATITUDE = "destination_latitude"
|
CONF_DESTINATION_LATITUDE = "destination_latitude"
|
||||||
CONF_DESTINATION_LONGITUDE = "destination_longitude"
|
CONF_DESTINATION_LONGITUDE = "destination_longitude"
|
||||||
CONF_DESTINATION_ENTITY_ID = "destination_entity_id"
|
CONF_DESTINATION_ENTITY_ID = "destination_entity_id"
|
||||||
|
CONF_ORIGIN = "origin"
|
||||||
CONF_ORIGIN_LATITUDE = "origin_latitude"
|
CONF_ORIGIN_LATITUDE = "origin_latitude"
|
||||||
CONF_ORIGIN_LONGITUDE = "origin_longitude"
|
CONF_ORIGIN_LONGITUDE = "origin_longitude"
|
||||||
CONF_ORIGIN_ENTITY_ID = "origin_entity_id"
|
CONF_ORIGIN_ENTITY_ID = "origin_entity_id"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user