Add Atag One thermostat integration (#32361)

* add atag integration

* ignore

* generated

* Update .gitignore

* requirements update

* update coveragerc

* Revert "update coveragerc"

* make entity_types more readable

* add DOMAIN to listener

* entity name

* Use DataUpdateCoordinator

* fix translations

* enable preset_modes

* fix water_heater

* update coveragerc

* remove scan_interval

Co-Authored-By: J. Nick Koston <nick@koston.org>

* Apply suggestions from code review

Co-Authored-By: Martin Hjelmare <marhje52@gmail.com>

* fixes review remarks

* fix flake8 errors

* ensure correct HVACmode

* add away mode

* use write_ha_state instead of refresh

* remove OFF support, add Fahrenheit

* rename test_config_flow.py

Co-authored-by: J. Nick Koston <nick@koston.org>
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
This commit is contained in:
authored and GitHub committed 2020-04-22 18:09:51 +02:00
1 parent 4a08c65205
commit ccc3ce81f9
15 files changed
+644

No files matched your search

+1
View File
@@ -0,0 +1 @@
"""Tests for the Atag component."""
+76
View File
@@ -0,0 +1,76 @@
"""Tests for the Atag config flow."""
from unittest.mock import PropertyMock
from asynctest import patch
from pyatag import AtagException
from homeassistant import config_entries, data_entry_flow
from homeassistant.components.atag import DOMAIN
from homeassistant.const import CONF_DEVICE, CONF_HOST, CONF_PORT
from tests.common import MockConfigEntry
FIXTURE_USER_INPUT = {
CONF_HOST: "127.0.0.1",
CONF_PORT: 10000,
}
FIXTURE_COMPLETE_ENTRY = FIXTURE_USER_INPUT.copy()
FIXTURE_COMPLETE_ENTRY[CONF_DEVICE] = "device_identifier"
async def test_show_form(hass):
"""Test that the form is served with no input."""
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
assert result["step_id"] == "user"
async def test_one_config_allowed(hass):
"""Test that only one Atag configuration is allowed."""
MockConfigEntry(domain="atag", data=FIXTURE_USER_INPUT).add_to_hass(hass)
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
assert result["reason"] == "already_configured"
async def test_connection_error(hass):
"""Test we show user form on Atag connection error."""
with patch(
"homeassistant.components.atag.config_flow.AtagDataStore.async_check_pair_status",
side_effect=AtagException(),
):
result = await hass.config_entries.flow.async_init(
DOMAIN,
context={"source": config_entries.SOURCE_USER},
data=FIXTURE_USER_INPUT,
)
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
assert result["step_id"] == "user"
assert result["errors"] == {"base": "connection_error"}
async def test_full_flow_implementation(hass):
"""Test registering an integration and finishing flow works."""
with patch(
"homeassistant.components.atag.AtagDataStore.async_check_pair_status",
), patch(
"homeassistant.components.atag.AtagDataStore.device",
new_callable=PropertyMock(return_value="device_identifier"),
):
result = await hass.config_entries.flow.async_init(
DOMAIN,
context={"source": config_entries.SOURCE_USER},
data=FIXTURE_USER_INPUT,
)
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
assert result["title"] == FIXTURE_COMPLETE_ENTRY[CONF_DEVICE]
assert result["data"] == FIXTURE_COMPLETE_ENTRY