Skip to content

Commit

Permalink
Code formatting updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Snuffy2 committed Sep 24, 2022
1 parent d079d1e commit 603d5ab
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 27 deletions.
53 changes: 33 additions & 20 deletions custom_components/places/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,15 @@ async def async_step_init(self, user_input=None):
user_input.setdefault(m, self.config_entry.data[m])
# Remove any keys with blank values
for m in dict(user_input).keys():
_LOGGER.debug("[Options Update] " + m + " [" + str(type(user_input.get(m))) + "]: " + str(user_input.get(m)))
if isinstance(user_input.get(m),str) and not user_input.get(m):
# _LOGGER.debug(
# "[Options Update] "
# + m
# + " ["
# + str(type(user_input.get(m)))
# + "]: "
# + str(user_input.get(m))
# )
if isinstance(user_input.get(m), str) and not user_input.get(m):
user_input.pop(m)
_LOGGER.debug(
"[Options Update] updated config: " + str(user_input))
Expand Down Expand Up @@ -248,18 +255,20 @@ async def async_step_init(self, user_input=None):
vol.Optional(
CONF_API_KEY,
default="",
description={"suggested_value":
self.config_entry.data[CONF_API_KEY]
description={
"suggested_value": self.config_entry.data[CONF_API_KEY]
if CONF_API_KEY in self.config_entry.data
else None},
else None
},
): str,
vol.Optional(
CONF_OPTIONS,
default=DEFAULT_OPTION,
description={"suggested_value":
self.config_entry.data[CONF_OPTIONS]
description={
"suggested_value": self.config_entry.data[CONF_OPTIONS]
if CONF_OPTIONS in self.config_entry.data
else DEFAULT_OPTION},
else DEFAULT_OPTION
},
): selector.SelectSelector(
selector.SelectSelectorConfig(
options=STATE_OPTIONS,
Expand All @@ -271,21 +280,23 @@ async def async_step_init(self, user_input=None):
vol.Optional(
CONF_HOME_ZONE,
default="",
description={"suggested_value":
self.config_entry.data[CONF_HOME_ZONE]
description={
"suggested_value": self.config_entry.data[CONF_HOME_ZONE]
if CONF_HOME_ZONE in self.config_entry.data
else None},
else None
},
): selector.EntitySelector(
selector.SingleEntitySelectorConfig(
domain=HOME_LOCATION_DOMAINS)
),
vol.Optional(
CONF_MAP_PROVIDER,
default=DEFAULT_MAP_PROVIDER,
description={"suggested_value":
self.config_entry.data[CONF_MAP_PROVIDER]
description={
"suggested_value": self.config_entry.data[CONF_MAP_PROVIDER]
if CONF_MAP_PROVIDER in self.config_entry.data
else DEFAULT_MAP_PROVIDER},
else DEFAULT_MAP_PROVIDER
},
): selector.SelectSelector(
selector.SelectSelectorConfig(
options=MAP_PROVIDER_OPTIONS,
Expand All @@ -297,10 +308,11 @@ async def async_step_init(self, user_input=None):
vol.Optional(
CONF_MAP_ZOOM,
default=DEFAULT_MAP_ZOOM,
description={"suggested_value":
self.config_entry.data[CONF_MAP_ZOOM]
description={
"suggested_value": self.config_entry.data[CONF_MAP_ZOOM]
if CONF_MAP_ZOOM in self.config_entry.data
else DEFAULT_MAP_ZOOM},
else DEFAULT_MAP_ZOOM
},
): selector.NumberSelector(
selector.NumberSelectorConfig(
min=MAP_ZOOM_MIN,
Expand All @@ -311,10 +323,11 @@ async def async_step_init(self, user_input=None):
vol.Optional(
CONF_LANGUAGE,
default="",
description={"suggested_value":
self.config_entry.data[CONF_LANGUAGE]
description={
"suggested_value": self.config_entry.data[CONF_LANGUAGE]
if CONF_LANGUAGE in self.config_entry.data
else None},
else None
},
): str,
vol.Optional(
CONF_EXTENDED_ATTR,
Expand Down
13 changes: 6 additions & 7 deletions custom_components/places/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
from homeassistant.components.repairs.models import (
IssueSeverity,
)

from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
from homeassistant.util import Throttle
from homeassistant.util.location import distance
Expand Down Expand Up @@ -108,8 +109,8 @@
DEFAULT_MAP_ZOOM,
DEFAULT_OPTION,
DOMAIN,
TRACKING_DOMAINS,
HOME_LOCATION_DOMAINS,
TRACKING_DOMAINS,
)

THROTTLE_INTERVAL = timedelta(seconds=600)
Expand Down Expand Up @@ -233,18 +234,16 @@ def do_import(_):
)
_LOGGER.error(ERROR)
return

if CONF_HOME_ZONE in import_config:
if import_config[CONF_HOME_ZONE] is None:
# home zone not defined in config
ERROR = "[YAML Import] Not importing: home_zone is blank in the YAML places sensor definition"
_LOGGER.error(ERROR)
return
_LOGGER.debug(
"[YAML Import] home_zone: " +
str(import_config[CONF_HOME_ZONE])
)

_LOGGER.debug("[YAML Import] home_zone: " +
str(import_config[CONF_HOME_ZONE]))

if import_config[CONF_HOME_ZONE].split(".")[0] not in HOME_LOCATION_DOMAINS:
# entity isn't in supported type
ERROR = (
Expand Down

0 comments on commit 603d5ab

Please sign in to comment.