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

View file

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