diff --git a/custom_components/bhyve/switch.py b/custom_components/bhyve/switch.py index 7de1df6..74e4b6e 100644 --- a/custom_components/bhyve/switch.py +++ b/custom_components/bhyve/switch.py @@ -356,7 +356,7 @@ def __init__(self, hass, bhyve, device, zone, device_programs, icon): self._zone = zone self._zone_id = zone.get("station") self._entity_picture = zone.get("image_url") - self._zone_name = zone.get("name") + self._zone_name = zone.get("name", "Unknown") self._smart_watering_enabled = zone.get("smart_watering_enabled") self._manual_preset_runtime = device.get( "manual_preset_runtime_sec", DEFAULT_MANUAL_RUNTIME.seconds diff --git a/custom_components/bhyve/util.py b/custom_components/bhyve/util.py index a12d90a..5747094 100755 --- a/custom_components/bhyve/util.py +++ b/custom_components/bhyve/util.py @@ -13,4 +13,13 @@ def orbit_time_to_local_time(timestamp: str): def filter_configured_devices(entry: ConfigEntry, all_devices): """Filter the device list to those that are enabled in options.""" - return [d for d in all_devices if str(d["id"]) in entry.options[CONF_DEVICES]] + filtered_devices = [ + d for d in all_devices if str(d["id"]) in entry.options[CONF_DEVICES] + ] + + # Ensure that all devices have a name + for device in filtered_devices: + if device.get("name") is None: + device["name"] = "Unknown Device" + + return filtered_devices