fix reading of battery messages (#70659)

This commit is contained in:
Markus Bong 2022-05-05 11:36:00 +02:00 committed by GitHub
parent 22d2587593
commit 248f01f41f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -7,6 +7,7 @@ from urllib.parse import urlparse
from devolo_home_control_api.devices.zwave import Zwave
from devolo_home_control_api.homecontrol import HomeControl
from homeassistant.components.sensor import SensorDeviceClass
from homeassistant.helpers.entity import DeviceInfo, Entity
from .const import DOMAIN
@ -71,7 +72,11 @@ class DevoloDeviceEntity(Entity):
def _generic_message(self, message: tuple) -> None:
"""Handle generic messages."""
if len(message) == 3 and message[2] == "battery_level":
if (
len(message) == 3
and message[2] == "battery_level"
and self.device_class == SensorDeviceClass.BATTERY
):
self._value = message[1]
elif len(message) == 3 and message[2] == "status":
# Maybe the API wants to tell us, that the device went on- or offline.