Remove invalid unit of measurement in mfi (#85620)

pull/84443/head
epenet 2023-01-10 16:45:59 +01:00 committed by GitHub
parent 298d7504fd
commit 4eddd8b75a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View File

@ -133,14 +133,14 @@ class MfiSensor(SensorEntity):
try:
tag = self._port.tag
except ValueError:
return "State"
return None
if tag == "temperature":
return UnitOfTemperature.CELSIUS
if tag == "active_pwr":
return "Watts"
if self._port.model == "Input Digital":
return "State"
return None
return tag
def update(self) -> None:

View File

@ -148,7 +148,7 @@ async def test_uom_power(port, sensor):
async def test_uom_digital(port, sensor):
"""Test the UOM digital input."""
port.model = "Input Digital"
assert sensor.unit_of_measurement == "State"
assert sensor.unit_of_measurement is None
assert sensor.device_class is None
@ -162,7 +162,7 @@ async def test_uom_unknown(port, sensor):
async def test_uom_uninitialized(port, sensor):
"""Test that the UOM defaults if not initialized."""
type(port).tag = mock.PropertyMock(side_effect=ValueError)
assert sensor.unit_of_measurement == "State"
assert sensor.unit_of_measurement is None
assert sensor.device_class is None