Use DeviceInfo in spider (#58575)

Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
epenet 2021-10-28 09:39:42 +02:00 committed by GitHub
parent 3e4d388491
commit b175f424d6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 26 deletions

View file

@ -8,6 +8,7 @@ from homeassistant.components.climate.const import (
SUPPORT_TARGET_TEMPERATURE,
)
from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS
from homeassistant.helpers.entity import DeviceInfo
from .const import DOMAIN
@ -46,14 +47,14 @@ class SpiderThermostat(ClimateEntity):
self.support_hvac.append(SPIDER_STATE_TO_HA[operation_value])
@property
def device_info(self):
def device_info(self) -> DeviceInfo:
"""Return the device_info of the device."""
return {
"identifiers": {(DOMAIN, self.thermostat.id)},
"name": self.thermostat.name,
"manufacturer": self.thermostat.manufacturer,
"model": self.thermostat.model,
}
return DeviceInfo(
identifiers={(DOMAIN, self.thermostat.id)},
manufacturer=self.thermostat.manufacturer,
model=self.thermostat.model,
name=self.thermostat.name,
)
@property
def supported_features(self):

View file

@ -42,12 +42,12 @@ class SpiderPowerPlugEnergy(SensorEntity):
@property
def device_info(self) -> DeviceInfo:
"""Return the device_info of the device."""
return {
"identifiers": {(DOMAIN, self.power_plug.id)},
"name": self.power_plug.name,
"manufacturer": self.power_plug.manufacturer,
"model": self.power_plug.model,
}
return DeviceInfo(
identifiers={(DOMAIN, self.power_plug.id)},
manufacturer=self.power_plug.manufacturer,
model=self.power_plug.model,
name=self.power_plug.name,
)
@property
def unique_id(self) -> str:
@ -84,12 +84,12 @@ class SpiderPowerPlugPower(SensorEntity):
@property
def device_info(self) -> DeviceInfo:
"""Return the device_info of the device."""
return {
"identifiers": {(DOMAIN, self.power_plug.id)},
"name": self.power_plug.name,
"manufacturer": self.power_plug.manufacturer,
"model": self.power_plug.model,
}
return DeviceInfo(
identifiers={(DOMAIN, self.power_plug.id)},
manufacturer=self.power_plug.manufacturer,
model=self.power_plug.model,
name=self.power_plug.name,
)
@property
def unique_id(self) -> str:

View file

@ -1,5 +1,6 @@
"""Support for Spider switches."""
from homeassistant.components.switch import SwitchEntity
from homeassistant.helpers.entity import DeviceInfo
from .const import DOMAIN
@ -24,14 +25,14 @@ class SpiderPowerPlug(SwitchEntity):
self.power_plug = power_plug
@property
def device_info(self):
def device_info(self) -> DeviceInfo:
"""Return the device_info of the device."""
return {
"identifiers": {(DOMAIN, self.power_plug.id)},
"name": self.power_plug.name,
"manufacturer": self.power_plug.manufacturer,
"model": self.power_plug.model,
}
return DeviceInfo(
identifiers={(DOMAIN, self.power_plug.id)},
manufacturer=self.power_plug.manufacturer,
model=self.power_plug.model,
name=self.power_plug.name,
)
@property
def unique_id(self):