Fix mysensors sensor protocol version check (#49257)

This commit is contained in:
Martin Hjelmare 2021-04-15 16:12:49 +02:00 committed by Franck Nijhof
parent ba0d3aad1c
commit 733a394c55
No known key found for this signature in database
GPG Key ID: D62583BA8AB11CA3

View File

@ -1,6 +1,8 @@
"""Support for MySensors sensors.""" """Support for MySensors sensors."""
from typing import Callable from typing import Callable
from awesomeversion import AwesomeVersion
from homeassistant.components import mysensors from homeassistant.components import mysensors
from homeassistant.components.mysensors import on_unload from homeassistant.components.mysensors import on_unload
from homeassistant.components.mysensors.const import MYSENSORS_DISCOVERY from homeassistant.components.mysensors.const import MYSENSORS_DISCOVERY
@ -115,7 +117,7 @@ class MySensorsSensor(mysensors.device.MySensorsEntity, SensorEntity):
"""Return the unit of measurement of this entity.""" """Return the unit of measurement of this entity."""
set_req = self.gateway.const.SetReq set_req = self.gateway.const.SetReq
if ( if (
float(self.gateway.protocol_version) >= 1.5 AwesomeVersion(self.gateway.protocol_version) >= AwesomeVersion("1.5")
and set_req.V_UNIT_PREFIX in self._values and set_req.V_UNIT_PREFIX in self._values
): ):
return self._values[set_req.V_UNIT_PREFIX] return self._values[set_req.V_UNIT_PREFIX]