Use DeviceInfo in smappee (#58522)

Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
epenet 2021-10-27 15:13:18 +02:00 committed by GitHub
parent e656974e8d
commit 8c1935ce0e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 24 deletions

View file

@ -3,6 +3,7 @@ from homeassistant.components.binary_sensor import (
DEVICE_CLASS_PRESENCE, DEVICE_CLASS_PRESENCE,
BinarySensorEntity, BinarySensorEntity,
) )
from homeassistant.helpers.entity import DeviceInfo
from .const import DOMAIN from .const import DOMAIN
@ -71,15 +72,15 @@ class SmappeePresence(BinarySensorEntity):
) )
@property @property
def device_info(self): def device_info(self) -> DeviceInfo:
"""Return the device info for this binary sensor.""" """Return the device info for this binary sensor."""
return { return DeviceInfo(
"identifiers": {(DOMAIN, self._service_location.device_serial_number)}, identifiers={(DOMAIN, self._service_location.device_serial_number)},
"name": self._service_location.service_location_name, manufacturer="Smappee",
"manufacturer": "Smappee", model=self._service_location.device_model,
"model": self._service_location.device_model, name=self._service_location.service_location_name,
"sw_version": self._service_location.firmware_version, sw_version=self._service_location.firmware_version,
} )
async def async_update(self): async def async_update(self):
"""Get the latest data from Smappee and update the state.""" """Get the latest data from Smappee and update the state."""
@ -154,15 +155,15 @@ class SmappeeAppliance(BinarySensorEntity):
) )
@property @property
def device_info(self): def device_info(self) -> DeviceInfo:
"""Return the device info for this binary sensor.""" """Return the device info for this binary sensor."""
return { return DeviceInfo(
"identifiers": {(DOMAIN, self._service_location.device_serial_number)}, identifiers={(DOMAIN, self._service_location.device_serial_number)},
"name": self._service_location.service_location_name, manufacturer="Smappee",
"manufacturer": "Smappee", model=self._service_location.device_model,
"model": self._service_location.device_model, name=self._service_location.service_location_name,
"sw_version": self._service_location.firmware_version, sw_version=self._service_location.firmware_version,
} )
async def async_update(self): async def async_update(self):
"""Get the latest data from Smappee and update the state.""" """Get the latest data from Smappee and update the state."""

View file

@ -18,6 +18,7 @@ from homeassistant.const import (
ENERGY_WATT_HOUR, ENERGY_WATT_HOUR,
POWER_WATT, POWER_WATT,
) )
from homeassistant.helpers.entity import DeviceInfo
from .const import DOMAIN from .const import DOMAIN
@ -372,15 +373,15 @@ class SmappeeSensor(SensorEntity):
) )
@property @property
def device_info(self): def device_info(self) -> DeviceInfo:
"""Return the device info for this sensor.""" """Return the device info for this sensor."""
return { return DeviceInfo(
"identifiers": {(DOMAIN, self._service_location.device_serial_number)}, identifiers={(DOMAIN, self._service_location.device_serial_number)},
"name": self._service_location.service_location_name, manufacturer="Smappee",
"manufacturer": "Smappee", model=self._service_location.device_model,
"model": self._service_location.device_model, name=self._service_location.service_location_name,
"sw_version": self._service_location.firmware_version, sw_version=self._service_location.firmware_version,
} )
async def async_update(self): async def async_update(self):
"""Get the latest data from Smappee and update the state.""" """Get the latest data from Smappee and update the state."""