Skip to content

Commit

Permalink
Merge pull request #195 from sebr/146/unnamed-entities
Browse files Browse the repository at this point in the history
146: Coalesce empty device names
  • Loading branch information
sebr authored May 27, 2023
2 parents affeeaf + 39ff52b commit 08f5d1a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion custom_components/bhyve/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 10 additions & 1 deletion custom_components/bhyve/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 08f5d1a

Please sign in to comment.