Skip to content
This repository has been archived by the owner on Oct 11, 2022. It is now read-only.

Commit

Permalink
Add unique_id and device_info (closes #39)
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidMStraub committed Nov 21, 2019
1 parent a6bbdf4 commit 4f61681
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion custom_components/homeconnect/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@
from homeassistant.core import callback


from .const import DOMAIN

_LOGGER = logging.getLogger(__name__)


class ConfigEntryAuth(homeconnect.HomeConnectAPI):
"""Provide Home Connect authentication tied to an OAuth2 based config entry."""

Expand Down Expand Up @@ -65,7 +68,6 @@ def get_devices(self):
return devices



class HomeConnectDevice:

# for some devices, this is instead 'BSH.Common.EnumType.PowerState.Standby'
Expand Down Expand Up @@ -115,6 +117,20 @@ def name(self):
"""Return the name of the node (used for Entity_ID)."""
return self._name

@property
def unique_id(self):
"""Return the unique id base on the id returned by Home Connect and the entity name."""
return f"{self.device.appliance.haId}-{self.name}"

@property
def device_info(self):
return {
"identifiers": {(DOMAIN, self.device.appliance.haId)},
"name": self.device.appliance.name,
"manufacturer": self.device.appliance.brand,
"model": self.device.appliance.vib,
}

@callback
def async_entity_update(self):
_LOGGER.debug("Entity update triggered on {}".format(self))
Expand Down

0 comments on commit 4f61681

Please sign in to comment.