Fix mysensors sensor protocol version check (#49257)

This commit is contained in:
Martin Hjelmare 2021-04-15 16:12:49 +02:00 committed by GitHub
parent 4f5c745492
commit 1b5148a3af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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]