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:
Matt Zimmerman
2023-11-06 14:51:04 +01:00
committed by Franck Nijhof
parent 412fa4c65a
commit 334a02bc2b
5 changed files with 30 additions and 4 deletions
+22
View File
@@ -2,6 +2,7 @@
import pytest
import smarttub
from homeassistant.const import STATE_UNKNOWN
from homeassistant.core import HomeAssistant
@@ -27,6 +28,27 @@ async def test_sensor(
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(
spa, spa_state, setup_entry, hass: HomeAssistant
) -> None: