Skip to content

Commit

Permalink
Fix device ID handling in device_trigger
Browse files Browse the repository at this point in the history
  • Loading branch information
jason0x43 committed Jun 3, 2022
1 parent 7ead476 commit 005ffa0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
8 changes: 3 additions & 5 deletions custom_components/hubitat/device_trigger.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, cast
import voluptuous as vol

from custom_components.hubitat.util import get_hubitat_device_id

from homeassistant.components.automation import (
AutomationActionType,
AutomationTriggerInfo,
Expand Down Expand Up @@ -201,11 +203,7 @@ def get_hubitat_device(
if device is None:
return None, None

hubitat_id = None
for identifier in device.identifiers:
if identifier[0] == DOMAIN:
hubitat_id = identifier[1]
break
hubitat_id = get_hubitat_device_id(device)

if hubitat_id is None:
_LOGGER.debug("Couldn't find Hubitat ID for device %s", device_id)
Expand Down
4 changes: 1 addition & 3 deletions custom_components/hubitat/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ def get_hub_device_id(hub: HasToken, device: Union[str, Device]) -> str:


def get_hubitat_device_id(device: DeviceEntry) -> Optional[str]:
for ids in device.identifiers:
id_set = ids[0]

for id_set in device.identifiers:
if id_set[0] == DOMAIN:
# The second identifier is hub_id:device_id
if ":" in id_set[1]:
Expand Down

0 comments on commit 005ffa0

Please sign in to comment.