mirror of
https://github.com/home-assistant/core.git
synced 2025-07-16 01:37:08 +00:00
Handle smarttub sensor values being None (#103385)
* [smarttub] handle sensor values being None * empty commit to rerun CI * lint * use const in test * reorder checks * use None instead of STATE_UNKNOWN * empty commit to rerun CI * check for STATE_UNKNOWN in test * empty commit to rerun CI
This commit is contained in:
parent
f6cb7e1bc5
commit
fd3d615c0d
@ -7,5 +7,5 @@
|
|||||||
"iot_class": "cloud_polling",
|
"iot_class": "cloud_polling",
|
||||||
"loggers": ["smarttub"],
|
"loggers": ["smarttub"],
|
||||||
"quality_scale": "platinum",
|
"quality_scale": "platinum",
|
||||||
"requirements": ["python-smarttub==0.0.33"]
|
"requirements": ["python-smarttub==0.0.35"]
|
||||||
}
|
}
|
||||||
|
@ -89,10 +89,14 @@ class SmartTubSensor(SmartTubSensorBase, SensorEntity):
|
|||||||
"""Generic class for SmartTub status sensors."""
|
"""Generic class for SmartTub status sensors."""
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def native_value(self) -> str:
|
def native_value(self) -> str | None:
|
||||||
"""Return the current state of the sensor."""
|
"""Return the current state of the sensor."""
|
||||||
|
if self._state is None:
|
||||||
|
return None
|
||||||
|
|
||||||
if isinstance(self._state, Enum):
|
if isinstance(self._state, Enum):
|
||||||
return self._state.name.lower()
|
return self._state.name.lower()
|
||||||
|
|
||||||
return self._state.lower()
|
return self._state.lower()
|
||||||
|
|
||||||
|
|
||||||
|
@ -2190,7 +2190,7 @@ python-ripple-api==0.0.3
|
|||||||
python-roborock==0.35.0
|
python-roborock==0.35.0
|
||||||
|
|
||||||
# homeassistant.components.smarttub
|
# homeassistant.components.smarttub
|
||||||
python-smarttub==0.0.33
|
python-smarttub==0.0.35
|
||||||
|
|
||||||
# homeassistant.components.songpal
|
# homeassistant.components.songpal
|
||||||
python-songpal==0.15.2
|
python-songpal==0.15.2
|
||||||
|
@ -1634,7 +1634,7 @@ python-qbittorrent==0.4.3
|
|||||||
python-roborock==0.35.0
|
python-roborock==0.35.0
|
||||||
|
|
||||||
# homeassistant.components.smarttub
|
# homeassistant.components.smarttub
|
||||||
python-smarttub==0.0.33
|
python-smarttub==0.0.35
|
||||||
|
|
||||||
# homeassistant.components.songpal
|
# homeassistant.components.songpal
|
||||||
python-songpal==0.15.2
|
python-songpal==0.15.2
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
import pytest
|
import pytest
|
||||||
import smarttub
|
import smarttub
|
||||||
|
|
||||||
|
from homeassistant.const import STATE_UNKNOWN
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
|
||||||
|
|
||||||
@ -27,6 +28,27 @@ async def test_sensor(
|
|||||||
assert state.state == expected_state
|
assert state.state == expected_state
|
||||||
|
|
||||||
|
|
||||||
|
# https://github.com/home-assistant/core/issues/102339
|
||||||
|
async def test_null_blowoutcycle(
|
||||||
|
spa,
|
||||||
|
spa_state,
|
||||||
|
config_entry,
|
||||||
|
hass: HomeAssistant,
|
||||||
|
) -> None:
|
||||||
|
"""Test blowoutCycle having null value."""
|
||||||
|
|
||||||
|
spa_state.blowout_cycle = None
|
||||||
|
|
||||||
|
config_entry.add_to_hass(hass)
|
||||||
|
await hass.config_entries.async_setup(config_entry.entry_id)
|
||||||
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
|
entity_id = f"sensor.{spa.brand}_{spa.model}_blowout_cycle"
|
||||||
|
state = hass.states.get(entity_id)
|
||||||
|
assert state is not None
|
||||||
|
assert state.state == STATE_UNKNOWN
|
||||||
|
|
||||||
|
|
||||||
async def test_primary_filtration(
|
async def test_primary_filtration(
|
||||||
spa, spa_state, setup_entry, hass: HomeAssistant
|
spa, spa_state, setup_entry, hass: HomeAssistant
|
||||||
) -> None:
|
) -> None:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user