From 59b1433e5c4227cc8c993cf6074395068c9e2692 Mon Sep 17 00:00:00 2001 From: Robert Svensson Date: Tue, 5 Oct 2021 09:17:45 +0200 Subject: [PATCH] Additional place to use isinstance rather than do a string compare (#57094) --- homeassistant/components/deconz/binary_sensor.py | 4 ++-- homeassistant/components/deconz/sensor.py | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/homeassistant/components/deconz/binary_sensor.py b/homeassistant/components/deconz/binary_sensor.py index 33b68f25cab..e0479d9a0c6 100644 --- a/homeassistant/components/deconz/binary_sensor.py +++ b/homeassistant/components/deconz/binary_sensor.py @@ -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 diff --git a/homeassistant/components/deconz/sensor.py b/homeassistant/components/deconz/sensor.py index 8b82c2fa7bf..ba8e5c8adec 100644 --- a/homeassistant/components/deconz/sensor.py +++ b/homeassistant/components/deconz/sensor.py @@ -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