Use DeviceInfo in screenlogic (#58518)

Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
epenet 2021-10-27 12:20:19 +02:00 committed by GitHub
parent a3dbe8e1e7
commit 9d3c75510f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -19,6 +19,7 @@ from homeassistant.core import HomeAssistant
from homeassistant.exceptions import ConfigEntryNotReady from homeassistant.exceptions import ConfigEntryNotReady
from homeassistant.helpers import device_registry as dr from homeassistant.helpers import device_registry as dr
from homeassistant.helpers.debounce import Debouncer from homeassistant.helpers.debounce import Debouncer
from homeassistant.helpers.entity import DeviceInfo
from homeassistant.helpers.typing import ConfigType from homeassistant.helpers.typing import ConfigType
from homeassistant.helpers.update_coordinator import ( from homeassistant.helpers.update_coordinator import (
CoordinatorEntity, CoordinatorEntity,
@ -215,7 +216,7 @@ class ScreenlogicEntity(CoordinatorEntity):
return self.gateway.name return self.gateway.name
@property @property
def device_info(self): def device_info(self) -> DeviceInfo:
"""Return device information for the controller.""" """Return device information for the controller."""
controller_type = self.config_data["controller_type"] controller_type = self.config_data["controller_type"]
hardware_type = self.config_data["hardware_type"] hardware_type = self.config_data["hardware_type"]
@ -225,12 +226,12 @@ class ScreenlogicEntity(CoordinatorEntity):
] ]
except KeyError: except KeyError:
equipment_model = f"Unknown Model C:{controller_type} H:{hardware_type}" equipment_model = f"Unknown Model C:{controller_type} H:{hardware_type}"
return { return DeviceInfo(
"connections": {(dr.CONNECTION_NETWORK_MAC, self.mac)}, connections={(dr.CONNECTION_NETWORK_MAC, self.mac)},
"name": self.gateway_name, manufacturer="Pentair",
"manufacturer": "Pentair", model=equipment_model,
"model": equipment_model, name=self.gateway_name,
} )
class ScreenLogicCircuitEntity(ScreenlogicEntity): class ScreenLogicCircuitEntity(ScreenlogicEntity):