Convert nuheat to use DataUpdateCoordinator (#42034)

* Convert nuheat to use DataUpdateCoordinator

* coverage

* Update homeassistant/components/nuheat/climate.py
This commit is contained in:
J. Nick Koston authored and GitHub committed 2020-10-18 13:45:47 -05:00
1 parent 37df7bf4c5
commit 8c27a99386
5 files changed
+81 -28

No files matched your search

+2
View File
@@ -103,6 +103,8 @@ def _get_mock_thermostat_schedule_temporary_hold():
target_celsius=43,
target_fahrenheit=99,
target_temperature=3729,
max_temperature=5000,
min_temperature=1,
)
thermostat.get_data = Mock()
+25
View File
@@ -1,6 +1,10 @@
"""The test for the NuHeat thermostat module."""
from datetime import timedelta
from homeassistant.components.nuheat.const import DOMAIN
from homeassistant.const import ATTR_ENTITY_ID
from homeassistant.setup import async_setup_component
import homeassistant.util.dt as dt_util
from .mocks import (
_get_mock_nuheat,
@@ -12,6 +16,7 @@ from .mocks import (
)
from tests.async_mock import patch
from tests.common import async_fire_time_changed
async def test_climate_thermostat_run(hass):
@@ -135,3 +140,23 @@ async def test_climate_thermostat_schedule_temporary_hold(hass):
# Only test for a subset of attributes in case
# HA changes the implementation and a new one appears
assert all(item in state.attributes.items() for item in expected_attributes.items())
await hass.services.async_call(
"climate",
"set_temperature",
service_data={ATTR_ENTITY_ID: "climate.temp_bathroom", "temperature": 90},
blocking=True,
)
await hass.async_block_till_done()
# opportunistic set
state = hass.states.get("climate.temp_bathroom")
assert state.attributes["preset_mode"] == "Temporary Hold"
assert state.attributes["temperature"] == 50.0
# and the api poll returns it to the mock
async_fire_time_changed(hass, dt_util.utcnow() + timedelta(seconds=3))
await hass.async_block_till_done()
state = hass.states.get("climate.temp_bathroom")
assert state.attributes["preset_mode"] == "Run Schedule"
assert state.attributes["temperature"] == 37.2