Additional place to use isinstance rather than do a string compare (#57094)

This commit is contained in:
Robert Svensson 2021-10-05 09:17:45 +02:00 committed by GitHub
parent b024d88b36
commit 59b1433e5c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 6 deletions

View File

@ -149,12 +149,12 @@ class DeconzBinarySensor(DeconzDevice, BinarySensorEntity):
if self._device.secondary_temperature is not None:
attr[ATTR_TEMPERATURE] = self._device.secondary_temperature
if self._device.type in Presence.ZHATYPE:
if isinstance(self._device, Presence):
if self._device.dark is not None:
attr[ATTR_DARK] = self._device.dark
elif self._device.type in Vibration.ZHATYPE:
elif isinstance(self._device, Vibration):
attr[ATTR_ORIENTATION] = self._device.orientation
attr[ATTR_TILTANGLE] = self._device.tilt_angle
attr[ATTR_VIBRATIONSTRENGTH] = self._device.vibration_strength

View File

@ -211,13 +211,13 @@ class DeconzSensor(DeconzDevice, SensorEntity):
if self._device.secondary_temperature is not None:
attr[ATTR_TEMPERATURE] = self._device.secondary_temperature
if self._device.type in Consumption.ZHATYPE:
if isinstance(self._device, Consumption):
attr[ATTR_POWER] = self._device.power
elif self._device.type in Daylight.ZHATYPE:
elif isinstance(self._device, Daylight):
attr[ATTR_DAYLIGHT] = self._device.daylight
elif self._device.type in LightLevel.ZHATYPE:
elif isinstance(self._device, LightLevel):
if self._device.dark is not None:
attr[ATTR_DARK] = self._device.dark
@ -225,7 +225,7 @@ class DeconzSensor(DeconzDevice, SensorEntity):
if self._device.daylight is not None:
attr[ATTR_DAYLIGHT] = self._device.daylight
elif self._device.type in Power.ZHATYPE:
elif isinstance(self._device, Power):
attr[ATTR_CURRENT] = self._device.current
attr[ATTR_VOLTAGE] = self._device.voltage