mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 06:07:17 +00:00
Remove invalid unit of measurement in mfi (#85620)
This commit is contained in:
parent
298d7504fd
commit
4eddd8b75a
@ -133,14 +133,14 @@ class MfiSensor(SensorEntity):
|
|||||||
try:
|
try:
|
||||||
tag = self._port.tag
|
tag = self._port.tag
|
||||||
except ValueError:
|
except ValueError:
|
||||||
return "State"
|
return None
|
||||||
|
|
||||||
if tag == "temperature":
|
if tag == "temperature":
|
||||||
return UnitOfTemperature.CELSIUS
|
return UnitOfTemperature.CELSIUS
|
||||||
if tag == "active_pwr":
|
if tag == "active_pwr":
|
||||||
return "Watts"
|
return "Watts"
|
||||||
if self._port.model == "Input Digital":
|
if self._port.model == "Input Digital":
|
||||||
return "State"
|
return None
|
||||||
return tag
|
return tag
|
||||||
|
|
||||||
def update(self) -> None:
|
def update(self) -> None:
|
||||||
|
@ -148,7 +148,7 @@ async def test_uom_power(port, sensor):
|
|||||||
async def test_uom_digital(port, sensor):
|
async def test_uom_digital(port, sensor):
|
||||||
"""Test the UOM digital input."""
|
"""Test the UOM digital input."""
|
||||||
port.model = "Input Digital"
|
port.model = "Input Digital"
|
||||||
assert sensor.unit_of_measurement == "State"
|
assert sensor.unit_of_measurement is None
|
||||||
assert sensor.device_class 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):
|
async def test_uom_uninitialized(port, sensor):
|
||||||
"""Test that the UOM defaults if not initialized."""
|
"""Test that the UOM defaults if not initialized."""
|
||||||
type(port).tag = mock.PropertyMock(side_effect=ValueError)
|
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
|
assert sensor.device_class is None
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user