Correct humidifier detection in venstar component and add tests (#50439)
As of version 0.14, the venstar_colortouch lib always initializes hum_setpoint to None. When a thermostat actually reports a humidifier state, this value is replaced with the integer value of the setpoint. This changeset corrects the humidifier detection as well as adds basic test cases for the Venstar component.
This commit is contained in:
parent
c74e65ac2d
commit
2ae91bf0ea
13 changed files with 149 additions and 3 deletions
57
tests/components/venstar/util.py
Normal file
57
tests/components/venstar/util.py
Normal file
|
@ -0,0 +1,57 @@
|
|||
"""Tests for the venstar integration."""
|
||||
|
||||
import requests_mock
|
||||
|
||||
from homeassistant.components.climate.const import DOMAIN
|
||||
from homeassistant.const import CONF_HOST, CONF_PLATFORM
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
from tests.common import load_fixture
|
||||
|
||||
TEST_MODELS = ["t2k", "colortouch"]
|
||||
|
||||
|
||||
def mock_venstar_devices(f):
|
||||
"""Decorate function to mock a Venstar Colortouch and T2000 thermostat API."""
|
||||
|
||||
async def wrapper(hass):
|
||||
# Mock thermostats are:
|
||||
# Venstar T2000, FW 4.38
|
||||
# Venstar "colortouch" T7850, FW 5.1
|
||||
with requests_mock.mock() as m:
|
||||
for model in TEST_MODELS:
|
||||
m.get(
|
||||
f"http://venstar-{model}.localdomain/",
|
||||
text=load_fixture(f"venstar/{model}_root.json"),
|
||||
)
|
||||
m.get(
|
||||
f"http://venstar-{model}.localdomain/query/info",
|
||||
text=load_fixture(f"venstar/{model}_info.json"),
|
||||
)
|
||||
m.get(
|
||||
f"http://venstar-{model}.localdomain/query/sensors",
|
||||
text=load_fixture(f"venstar/{model}_sensors.json"),
|
||||
)
|
||||
return await f(hass)
|
||||
|
||||
return wrapper
|
||||
|
||||
|
||||
async def async_init_integration(
|
||||
hass: HomeAssistant,
|
||||
skip_setup: bool = False,
|
||||
):
|
||||
"""Set up the venstar integration in Home Assistant."""
|
||||
platform_config = []
|
||||
for model in TEST_MODELS:
|
||||
platform_config.append(
|
||||
{
|
||||
CONF_PLATFORM: "venstar",
|
||||
CONF_HOST: f"venstar-{model}.localdomain",
|
||||
}
|
||||
)
|
||||
config = {DOMAIN: platform_config}
|
||||
|
||||
await async_setup_component(hass, DOMAIN, config)
|
||||
await hass.async_block_till_done()
|
Loading…
Add table
Add a link
Reference in a new issue