Skip to content

Commit

Permalink
Configured create_sensors error after Home Assistant upgrade #13
Browse files Browse the repository at this point in the history
  • Loading branch information
rodpayne committed Dec 20, 2023
1 parent 6c54ed0 commit d99893a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
16 changes: 11 additions & 5 deletions custom_components/person_location/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,17 @@
ATTR_UNIT_OF_MEASUREMENT,
STATE_UNKNOWN,
)
from homeassistant.util.yaml.objects import (
NodeListClass,
NodeStrClass,
)

# Our info:
DOMAIN = "person_location"
API_STATE_OBJECT = DOMAIN + "." + DOMAIN + "_integration"
INTEGRATION_NAME = "Person Location"
ISSUE_URL = "https://github.com/rodpayne/home-assistant/issues"
VERSION = "2023.12.09"
VERSION = "2023.12.20"

# Fixed parameters:
MIN_DISTANCE_TRAVELLED_TO_GEOCODE = 5
Expand Down Expand Up @@ -266,17 +270,19 @@ def __init__(self, _entity_id, _hass, _config):
self.configuration[CONF_WAZE_REGION],
)
raw_conf_create_sensors = self.config[DOMAIN].get(CONF_CREATE_SENSORS, [])
if type(raw_conf_create_sensors) == list:
itemType = type(raw_conf_create_sensors)
if (itemType == list) or (itemType == NodeListClass):
self.configuration[CONF_CREATE_SENSORS] = sorted(raw_conf_create_sensors)
elif type(raw_conf_create_sensors) == str:
elif (itemType == str) or (itemType == NodeStrClass):
self.configuration[CONF_CREATE_SENSORS] = sorted([
x.strip() for x in raw_conf_create_sensors.split(",")
])
else:
_LOGGER.error(
"Configured %s: %s is not valid",
"Configured %s: %s is not valid (type %s)",
CONF_CREATE_SENSORS,
raw_conf_create_sensors,
itemType,
)
self.configuration[CONF_CREATE_SENSORS] = []
for sensor_name in self.configuration[CONF_CREATE_SENSORS]:
Expand All @@ -295,7 +301,7 @@ def __init__(self, _entity_id, _hass, _config):
person_name = person_name_config[CONF_NAME]
_LOGGER.debug("person_name_config name = %s", person_name)
devices = person_name_config[CONF_DEVICES]
if type(devices) == str:
if (type(devices) == str) or (type(devices) == NodeStrClass):
devices = [devices]
for device in devices:
_LOGGER.debug("person_name_config device = %s", device)
Expand Down
2 changes: 1 addition & 1 deletion custom_components/person_location/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@
"iot_class": "calculated",
"issue_tracker": "https://github.com/rodpayne/home-assistant_person_location/issues",
"requirements": [],
"version": "2023.12.09"
"version": "2023.12.20"
}

0 comments on commit d99893a

Please sign in to comment.