Use DeviceInfo in wemo (#58638)

This commit is contained in:
epenet 2021-10-28 23:58:33 +02:00 committed by GitHub
parent 37930aeeb6
commit 107bd11a31
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 15 deletions

View file

@ -17,6 +17,7 @@ from homeassistant.components.light import (
from homeassistant.core import callback from homeassistant.core import callback
from homeassistant.helpers.device_registry import CONNECTION_ZIGBEE from homeassistant.helpers.device_registry import CONNECTION_ZIGBEE
from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.helpers.entity import DeviceInfo
import homeassistant.util.color as color_util import homeassistant.util.color as color_util
from .const import DOMAIN as WEMO_DOMAIN from .const import DOMAIN as WEMO_DOMAIN
@ -99,15 +100,15 @@ class WemoLight(WemoEntity, LightEntity):
return self.light.uniqueID return self.light.uniqueID
@property @property
def device_info(self): def device_info(self) -> DeviceInfo:
"""Return the device info.""" """Return the device info."""
return { return DeviceInfo(
"name": self.name, connections={(CONNECTION_ZIGBEE, self._unique_id)},
"connections": {(CONNECTION_ZIGBEE, self._unique_id)}, identifiers={(WEMO_DOMAIN, self._unique_id)},
"identifiers": {(WEMO_DOMAIN, self._unique_id)}, manufacturer="Belkin",
"model": self._model_name, model=self._model_name,
"manufacturer": "Belkin", name=self.name,
} )
@property @property
def brightness(self): def brightness(self):

View file

@ -17,6 +17,7 @@ from homeassistant.const import (
) )
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.device_registry import async_get as async_get_device_registry from homeassistant.helpers.device_registry import async_get as async_get_device_registry
from homeassistant.helpers.entity import DeviceInfo
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
from .const import DOMAIN, WEMO_SUBSCRIPTION_EVENT from .const import DOMAIN, WEMO_SUBSCRIPTION_EVENT
@ -120,13 +121,13 @@ class DeviceCoordinator(DataUpdateCoordinator):
raise UpdateFailed("WeMo update failed") from err raise UpdateFailed("WeMo update failed") from err
def _device_info(wemo: WeMoDevice): def _device_info(wemo: WeMoDevice) -> DeviceInfo:
return { return DeviceInfo(
"name": wemo.name, identifiers={(DOMAIN, wemo.serialnumber)},
"identifiers": {(DOMAIN, wemo.serialnumber)}, manufacturer="Belkin",
"model": wemo.model_name, model=wemo.model_name,
"manufacturer": "Belkin", name=wemo.name,
} )
async def async_register_device( async def async_register_device(