Skip to content

Commit

Permalink
Deduplicate entity types
Browse files Browse the repository at this point in the history
  • Loading branch information
dan-r committed Jan 15, 2024
1 parent 713d7ec commit 86ebfba
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
8 changes: 5 additions & 3 deletions custom_components/ohme/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ async def async_setup_entry(hass, entry):
hass.data[DOMAIN][DATA_COORDINATORS] = coordinators

# Create tasks for each entity type
entity_types = ["sensor", "binary_sensor", "switch", "button", "number", "time"]
for entity_type in entity_types:
for entity_type in ENTITY_TYPES:
hass.async_create_task(
hass.config_entries.async_forward_entry_setup(entry, entity_type)
)
Expand All @@ -77,4 +76,7 @@ async def async_setup_entry(hass, entry):
async def async_unload_entry(hass, entry):
"""Unload a config entry."""

return await hass.config_entries.async_unload_platforms(entry, ['binary_sensor', 'sensor', 'switch'])
return await hass.config_entries.async_unload_platforms(entry, ENTITY_TYPES)

async def async_migrate_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> bool:
"""Migrate old entry."""
1 change: 1 addition & 0 deletions custom_components/ohme/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
DOMAIN = "ohme"
USER_AGENT = "dan-r-homeassistant-ohme"
INTEGRATION_VERSION = "0.3.2"
ENTITY_TYPES = ["sensor", "binary_sensor", "switch", "button", "number", "time"]

DATA_CLIENT = "client"
DATA_COORDINATORS = "coordinators"
Expand Down

0 comments on commit 86ebfba

Please sign in to comment.