From bb9ea7ce6eaac2032d4514118fa17a68405088b5 Mon Sep 17 00:00:00 2001 From: Tom Date: Tue, 8 Sep 2020 08:37:44 +0200 Subject: [PATCH] Add tests for Plugwise integration (#36371) --- .coveragerc | 5 - .../components/plugwise/config_flow.py | 1 - requirements_test.txt | 1 + tests/components/plugwise/common.py | 26 +++ tests/components/plugwise/conftest.py | 167 ++++++++++++++++++ .../components/plugwise/test_binary_sensor.py | 37 ++++ tests/components/plugwise/test_climate.py | 161 +++++++++++++++++ tests/components/plugwise/test_config_flow.py | 5 +- tests/components/plugwise/test_init.py | 45 +++++ tests/components/plugwise/test_sensor.py | 66 +++++++ tests/components/plugwise/test_switch.py | 50 ++++++ .../get_all_devices.json | 1 + .../02cf28bfec924855854c544690a609ef.json | 1 + .../21f2b542c49845e6bb416884c55778d6.json | 1 + .../4a810418d5394b3f82727340b91ba740.json | 1 + .../675416a629f343c495449970e2ca37b5.json | 1 + .../680423ff840043738f42cc7f1ff97a36.json | 1 + .../6a3bf693d05e48e0b460c815a4fdd09d.json | 1 + .../78d1126fc4c743db81b61c20e88342a7.json | 1 + .../90986d591dcd426cae3ec3e8111ff730.json | 1 + .../a28f588dc4a049a483fd03a30361ad3a.json | 1 + .../a2c3583e0a6349358998b760cea82d2a.json | 1 + .../b310b72a0e354bfab43089919b9a88bf.json | 1 + .../b59bcebaf94b499ea7d46e4a66fb62d8.json | 1 + .../cd0ddb54ef694e11ac18ed1cbce5dbbd.json | 1 + .../d3da73bde12a47d5a6b8f9dad971f2ec.json | 1 + .../df4a4a8169904cdb9c03d61a21f42140.json | 1 + .../e7693eb9582644e5b865dba8d4447cf1.json | 1 + .../f1fee6043d3642a9b0a65297455f008e.json | 1 + .../fe799307f1624099878210aa0b9f1475.json | 1 + .../anna_heatpump/get_all_devices.json | 1 + .../015ae9ea3f964e668e490fa39da3870b.json | 1 + .../1cbf783bb11e4a7c8a6843dee3a86927.json | 1 + .../3cb70739631c4d17a86b8b12e8a5161b.json | 1 + .../p1v3_full_option/get_all_devices.json | 1 + .../e950c7d5e1ee407a858e2a8b5016c8b3.json | 1 + 36 files changed, 580 insertions(+), 9 deletions(-) create mode 100644 tests/components/plugwise/common.py create mode 100644 tests/components/plugwise/conftest.py create mode 100644 tests/components/plugwise/test_binary_sensor.py create mode 100644 tests/components/plugwise/test_climate.py create mode 100644 tests/components/plugwise/test_init.py create mode 100644 tests/components/plugwise/test_sensor.py create mode 100644 tests/components/plugwise/test_switch.py create mode 100644 tests/fixtures/plugwise/adam_multiple_devices_per_zone/get_all_devices.json create mode 100644 tests/fixtures/plugwise/adam_multiple_devices_per_zone/get_device_data/02cf28bfec924855854c544690a609ef.json create mode 100644 tests/fixtures/plugwise/adam_multiple_devices_per_zone/get_device_data/21f2b542c49845e6bb416884c55778d6.json create mode 100644 tests/fixtures/plugwise/adam_multiple_devices_per_zone/get_device_data/4a810418d5394b3f82727340b91ba740.json create mode 100644 tests/fixtures/plugwise/adam_multiple_devices_per_zone/get_device_data/675416a629f343c495449970e2ca37b5.json create mode 100644 tests/fixtures/plugwise/adam_multiple_devices_per_zone/get_device_data/680423ff840043738f42cc7f1ff97a36.json create mode 100644 tests/fixtures/plugwise/adam_multiple_devices_per_zone/get_device_data/6a3bf693d05e48e0b460c815a4fdd09d.json create mode 100644 tests/fixtures/plugwise/adam_multiple_devices_per_zone/get_device_data/78d1126fc4c743db81b61c20e88342a7.json create mode 100644 tests/fixtures/plugwise/adam_multiple_devices_per_zone/get_device_data/90986d591dcd426cae3ec3e8111ff730.json create mode 100644 tests/fixtures/plugwise/adam_multiple_devices_per_zone/get_device_data/a28f588dc4a049a483fd03a30361ad3a.json create mode 100644 tests/fixtures/plugwise/adam_multiple_devices_per_zone/get_device_data/a2c3583e0a6349358998b760cea82d2a.json create mode 100644 tests/fixtures/plugwise/adam_multiple_devices_per_zone/get_device_data/b310b72a0e354bfab43089919b9a88bf.json create mode 100644 tests/fixtures/plugwise/adam_multiple_devices_per_zone/get_device_data/b59bcebaf94b499ea7d46e4a66fb62d8.json create mode 100644 tests/fixtures/plugwise/adam_multiple_devices_per_zone/get_device_data/cd0ddb54ef694e11ac18ed1cbce5dbbd.json create mode 100644 tests/fixtures/plugwise/adam_multiple_devices_per_zone/get_device_data/d3da73bde12a47d5a6b8f9dad971f2ec.json create mode 100644 tests/fixtures/plugwise/adam_multiple_devices_per_zone/get_device_data/df4a4a8169904cdb9c03d61a21f42140.json create mode 100644 tests/fixtures/plugwise/adam_multiple_devices_per_zone/get_device_data/e7693eb9582644e5b865dba8d4447cf1.json create mode 100644 tests/fixtures/plugwise/adam_multiple_devices_per_zone/get_device_data/f1fee6043d3642a9b0a65297455f008e.json create mode 100644 tests/fixtures/plugwise/adam_multiple_devices_per_zone/get_device_data/fe799307f1624099878210aa0b9f1475.json create mode 100644 tests/fixtures/plugwise/anna_heatpump/get_all_devices.json create mode 100644 tests/fixtures/plugwise/anna_heatpump/get_device_data/015ae9ea3f964e668e490fa39da3870b.json create mode 100644 tests/fixtures/plugwise/anna_heatpump/get_device_data/1cbf783bb11e4a7c8a6843dee3a86927.json create mode 100644 tests/fixtures/plugwise/anna_heatpump/get_device_data/3cb70739631c4d17a86b8b12e8a5161b.json create mode 100644 tests/fixtures/plugwise/p1v3_full_option/get_all_devices.json create mode 100644 tests/fixtures/plugwise/p1v3_full_option/get_device_data/e950c7d5e1ee407a858e2a8b5016c8b3.json diff --git a/.coveragerc b/.coveragerc index 56a52b4f4e5..6b1ef2f152a 100644 --- a/.coveragerc +++ b/.coveragerc @@ -657,11 +657,6 @@ omit = homeassistant/components/plaato/* homeassistant/components/plex/media_player.py homeassistant/components/plex/sensor.py - homeassistant/components/plugwise/__init__.py - homeassistant/components/plugwise/binary_sensor.py - homeassistant/components/plugwise/climate.py - homeassistant/components/plugwise/sensor.py - homeassistant/components/plugwise/switch.py homeassistant/components/plum_lightpad/light.py homeassistant/components/pocketcasts/sensor.py homeassistant/components/point/* diff --git a/homeassistant/components/plugwise/config_flow.py b/homeassistant/components/plugwise/config_flow.py index 4d1752a2774..20c8a5a216c 100644 --- a/homeassistant/components/plugwise/config_flow.py +++ b/homeassistant/components/plugwise/config_flow.py @@ -106,7 +106,6 @@ class PlugwiseConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): except Exception: # pylint: disable=broad-except _LOGGER.exception("Unexpected exception") errors["base"] = "unknown" - if not errors: await self.async_set_unique_id(api.gateway_id) self._abort_if_unique_id_configured() diff --git a/requirements_test.txt b/requirements_test.txt index 86b8b496e83..e36837edf63 100644 --- a/requirements_test.txt +++ b/requirements_test.txt @@ -7,6 +7,7 @@ asynctest==0.13.0 codecov==2.1.0 coverage==5.2.1 +jsonpickle==1.4.1 mock-open==1.4.0 mypy==0.780 pre-commit==2.7.1 diff --git a/tests/components/plugwise/common.py b/tests/components/plugwise/common.py new file mode 100644 index 00000000000..eb227322aa8 --- /dev/null +++ b/tests/components/plugwise/common.py @@ -0,0 +1,26 @@ +"""Common initialisation for the Plugwise integration.""" + +from homeassistant.components.plugwise import DOMAIN +from homeassistant.core import HomeAssistant + +from tests.common import MockConfigEntry +from tests.test_util.aiohttp import AiohttpClientMocker + + +async def async_init_integration( + hass: HomeAssistant, + aioclient_mock: AiohttpClientMocker, + skip_setup: bool = False, +): + """Initialize the Smile integration.""" + + entry = MockConfigEntry( + domain=DOMAIN, data={"host": "1.1.1.1", "password": "test-password"} + ) + entry.add_to_hass(hass) + + if not skip_setup: + await hass.config_entries.async_setup(entry.entry_id) + await hass.async_block_till_done() + + return entry diff --git a/tests/components/plugwise/conftest.py b/tests/components/plugwise/conftest.py new file mode 100644 index 00000000000..8564b2c0d8c --- /dev/null +++ b/tests/components/plugwise/conftest.py @@ -0,0 +1,167 @@ +"""Setup mocks for the Plugwise integration tests.""" + +from functools import partial +import re + +from Plugwise_Smile.Smile import Smile +import jsonpickle +import pytest + +from tests.async_mock import AsyncMock, patch +from tests.common import load_fixture +from tests.test_util.aiohttp import AiohttpClientMocker + + +def _read_json(environment, call): + """Undecode the json data.""" + fixture = load_fixture(f"plugwise/{environment}/{call}.json") + return jsonpickle.decode(fixture) + + +@pytest.fixture(name="mock_smile") +def mock_smile(): + """Create a Mock Smile for testing exceptions.""" + with patch( + "homeassistant.components.plugwise.config_flow.Smile", + ) as smile_mock: + smile_mock.InvalidAuthentication = Smile.InvalidAuthentication + smile_mock.ConnectionFailedError = Smile.ConnectionFailedError + smile_mock.return_value.connect.return_value = True + yield smile_mock.return_value + + +@pytest.fixture(name="mock_smile_unauth") +def mock_smile_unauth(aioclient_mock: AiohttpClientMocker) -> None: + """Mock the Plugwise Smile unauthorized for Home Assistant.""" + aioclient_mock.get(re.compile(".*"), status=401) + aioclient_mock.put(re.compile(".*"), status=401) + + +@pytest.fixture(name="mock_smile_error") +def mock_smile_error(aioclient_mock: AiohttpClientMocker) -> None: + """Mock the Plugwise Smile server failure for Home Assistant.""" + aioclient_mock.get(re.compile(".*"), status=500) + aioclient_mock.put(re.compile(".*"), status=500) + + +@pytest.fixture(name="mock_smile_notconnect") +def mock_smile_notconnect(): + """Mock the Plugwise Smile general connection failure for Home Assistant.""" + with patch("homeassistant.components.plugwise.Smile") as smile_mock: + smile_mock.InvalidAuthentication = Smile.InvalidAuthentication + smile_mock.ConnectionFailedError = Smile.ConnectionFailedError + smile_mock.PlugwiseError = Smile.PlugwiseError + smile_mock.return_value.connect.side_effect = AsyncMock(return_value=False) + yield smile_mock.return_value + + +def _get_device_data(chosen_env, device_id): + """Mock return data for specific devices.""" + return _read_json(chosen_env, "get_device_data/" + device_id) + + +@pytest.fixture(name="mock_smile_adam") +def mock_smile_adam(): + """Create a Mock Adam environment for testing exceptions.""" + chosen_env = "adam_multiple_devices_per_zone" + with patch("homeassistant.components.plugwise.Smile") as smile_mock: + smile_mock.InvalidAuthentication = Smile.InvalidAuthentication + smile_mock.ConnectionFailedError = Smile.ConnectionFailedError + smile_mock.XMLDataMissingError = Smile.XMLDataMissingError + + smile_mock.return_value.gateway_id = "fe799307f1624099878210aa0b9f1475" + smile_mock.return_value.heater_id = "90986d591dcd426cae3ec3e8111ff730" + smile_mock.return_value.smile_version = "3.0.15" + smile_mock.return_value.smile_type = "thermostat" + + smile_mock.return_value.connect.side_effect = AsyncMock(return_value=True) + smile_mock.return_value.full_update_device.side_effect = AsyncMock( + return_value=True + ) + smile_mock.return_value.set_schedule_state.side_effect = AsyncMock( + return_value=True + ) + smile_mock.return_value.set_preset.side_effect = AsyncMock(return_value=True) + smile_mock.return_value.set_temperature.side_effect = AsyncMock( + return_value=True + ) + smile_mock.return_value.set_relay_state.side_effect = AsyncMock( + return_value=True + ) + + smile_mock.return_value.get_all_devices.return_value = _read_json( + chosen_env, "get_all_devices" + ) + smile_mock.return_value.get_device_data.side_effect = partial( + _get_device_data, chosen_env + ) + + yield smile_mock.return_value + + +@pytest.fixture(name="mock_smile_anna") +def mock_smile_anna(): + """Create a Mock Anna environment for testing exceptions.""" + chosen_env = "anna_heatpump" + with patch("homeassistant.components.plugwise.Smile") as smile_mock: + smile_mock.InvalidAuthentication = Smile.InvalidAuthentication + smile_mock.ConnectionFailedError = Smile.ConnectionFailedError + smile_mock.XMLDataMissingError = Smile.XMLDataMissingError + + smile_mock.return_value.gateway_id = "015ae9ea3f964e668e490fa39da3870b" + smile_mock.return_value.heater_id = "1cbf783bb11e4a7c8a6843dee3a86927" + smile_mock.return_value.smile_version = "4.0.15" + smile_mock.return_value.smile_type = "thermostat" + + smile_mock.return_value.connect.side_effect = AsyncMock(return_value=True) + smile_mock.return_value.full_update_device.side_effect = AsyncMock( + return_value=True + ) + smile_mock.return_value.set_schedule_state.side_effect = AsyncMock( + return_value=True + ) + smile_mock.return_value.set_preset.side_effect = AsyncMock(return_value=True) + smile_mock.return_value.set_temperature.side_effect = AsyncMock( + return_value=True + ) + smile_mock.return_value.set_relay_state.side_effect = AsyncMock( + return_value=True + ) + + smile_mock.return_value.get_all_devices.return_value = _read_json( + chosen_env, "get_all_devices" + ) + smile_mock.return_value.get_device_data.side_effect = partial( + _get_device_data, chosen_env + ) + + yield smile_mock.return_value + + +@pytest.fixture(name="mock_smile_p1") +def mock_smile_p1(): + """Create a Mock P1 DSMR environment for testing exceptions.""" + chosen_env = "p1v3_full_option" + with patch("homeassistant.components.plugwise.Smile") as smile_mock: + smile_mock.InvalidAuthentication = Smile.InvalidAuthentication + smile_mock.ConnectionFailedError = Smile.ConnectionFailedError + smile_mock.XMLDataMissingError = Smile.XMLDataMissingError + + smile_mock.return_value.gateway_id = "e950c7d5e1ee407a858e2a8b5016c8b3" + smile_mock.return_value.heater_id = None + smile_mock.return_value.smile_version = "3.3.9" + smile_mock.return_value.smile_type = "power" + + smile_mock.return_value.connect.side_effect = AsyncMock(return_value=True) + smile_mock.return_value.full_update_device.side_effect = AsyncMock( + return_value=True + ) + + smile_mock.return_value.get_all_devices.return_value = _read_json( + chosen_env, "get_all_devices" + ) + smile_mock.return_value.get_device_data.side_effect = partial( + _get_device_data, chosen_env + ) + + yield smile_mock.return_value diff --git a/tests/components/plugwise/test_binary_sensor.py b/tests/components/plugwise/test_binary_sensor.py new file mode 100644 index 00000000000..b2221194d8e --- /dev/null +++ b/tests/components/plugwise/test_binary_sensor.py @@ -0,0 +1,37 @@ +"""Tests for the Plugwise binary_sensor integration.""" + +from homeassistant.config_entries import ENTRY_STATE_LOADED +from homeassistant.const import STATE_OFF, STATE_ON + +from tests.components.plugwise.common import async_init_integration + + +async def test_anna_climate_binary_sensor_entities(hass, mock_smile_anna): + """Test creation of climate related binary_sensor entities.""" + entry = await async_init_integration(hass, mock_smile_anna) + assert entry.state == ENTRY_STATE_LOADED + + state = hass.states.get("binary_sensor.auxiliary_slave_boiler_state") + assert str(state.state) == STATE_OFF + + state = hass.states.get("binary_sensor.auxiliary_dhw_state") + assert str(state.state) == STATE_OFF + + +async def test_anna_climate_binary_sensor_change(hass, mock_smile_anna): + """Test change of climate related binary_sensor entities.""" + entry = await async_init_integration(hass, mock_smile_anna) + assert entry.state == ENTRY_STATE_LOADED + + hass.states.async_set("binary_sensor.auxiliary_dhw_state", STATE_ON, {}) + await hass.async_block_till_done() + + state = hass.states.get("binary_sensor.auxiliary_dhw_state") + assert str(state.state) == STATE_ON + + await hass.helpers.entity_component.async_update_entity( + "binary_sensor.auxiliary_dhw_state" + ) + + state = hass.states.get("binary_sensor.auxiliary_dhw_state") + assert str(state.state) == STATE_OFF diff --git a/tests/components/plugwise/test_climate.py b/tests/components/plugwise/test_climate.py new file mode 100644 index 00000000000..02375b49709 --- /dev/null +++ b/tests/components/plugwise/test_climate.py @@ -0,0 +1,161 @@ +"""Tests for the Plugwise Climate integration.""" + +from homeassistant.config_entries import ENTRY_STATE_LOADED + +from tests.components.plugwise.common import async_init_integration + + +async def test_adam_climate_entity_attributes(hass, mock_smile_adam): + """Test creation of adam climate device environment.""" + entry = await async_init_integration(hass, mock_smile_adam) + assert entry.state == ENTRY_STATE_LOADED + + state = hass.states.get("climate.zone_lisa_wk") + attrs = state.attributes + + assert attrs["hvac_modes"] is None + + assert "preset_modes" in attrs + assert "no_frost" in attrs["preset_modes"] + assert "home" in attrs["preset_modes"] + + assert attrs["current_temperature"] == 20.9 + assert attrs["temperature"] == 21.5 + + assert attrs["preset_mode"] == "home" + + assert attrs["supported_features"] == 17 + + state = hass.states.get("climate.zone_thermostat_jessie") + attrs = state.attributes + + assert attrs["hvac_modes"] is None + + assert "preset_modes" in attrs + assert "no_frost" in attrs["preset_modes"] + assert "home" in attrs["preset_modes"] + + assert attrs["current_temperature"] == 17.2 + assert attrs["temperature"] == 15.0 + + assert attrs["preset_mode"] == "asleep" + + +async def test_adam_climate_entity_climate_changes(hass, mock_smile_adam): + """Test handling of user requests in adam climate device environment.""" + entry = await async_init_integration(hass, mock_smile_adam) + assert entry.state == ENTRY_STATE_LOADED + + await hass.services.async_call( + "climate", + "set_temperature", + {"entity_id": "climate.zone_lisa_wk", "temperature": 25}, + blocking=True, + ) + state = hass.states.get("climate.zone_lisa_wk") + attrs = state.attributes + + assert attrs["temperature"] == 25.0 + + await hass.services.async_call( + "climate", + "set_preset_mode", + {"entity_id": "climate.zone_lisa_wk", "preset_mode": "away"}, + blocking=True, + ) + state = hass.states.get("climate.zone_lisa_wk") + attrs = state.attributes + + assert attrs["preset_mode"] == "away" + + assert attrs["supported_features"] == 17 + + await hass.services.async_call( + "climate", + "set_temperature", + {"entity_id": "climate.zone_thermostat_jessie", "temperature": 25}, + blocking=True, + ) + + state = hass.states.get("climate.zone_thermostat_jessie") + attrs = state.attributes + + assert attrs["temperature"] == 25.0 + + await hass.services.async_call( + "climate", + "set_preset_mode", + {"entity_id": "climate.zone_thermostat_jessie", "preset_mode": "home"}, + blocking=True, + ) + state = hass.states.get("climate.zone_thermostat_jessie") + attrs = state.attributes + + assert attrs["preset_mode"] == "home" + + +async def test_anna_climate_entity_attributes(hass, mock_smile_anna): + """Test creation of anna climate device environment.""" + entry = await async_init_integration(hass, mock_smile_anna) + assert entry.state == ENTRY_STATE_LOADED + + state = hass.states.get("climate.anna") + attrs = state.attributes + + assert "hvac_modes" in attrs + assert "heat_cool" in attrs["hvac_modes"] + + assert "preset_modes" in attrs + assert "no_frost" in attrs["preset_modes"] + assert "home" in attrs["preset_modes"] + + assert attrs["current_temperature"] == 23.3 + assert attrs["temperature"] == 21.0 + + assert state.state == "auto" + assert attrs["hvac_action"] == "idle" + assert attrs["preset_mode"] == "home" + + assert attrs["supported_features"] == 17 + + +async def test_anna_climate_entity_climate_changes(hass, mock_smile_anna): + """Test handling of user requests in anna climate device environment.""" + entry = await async_init_integration(hass, mock_smile_anna) + assert entry.state == ENTRY_STATE_LOADED + + await hass.services.async_call( + "climate", + "set_temperature", + {"entity_id": "climate.anna", "temperature": 25}, + blocking=True, + ) + + state = hass.states.get("climate.anna") + attrs = state.attributes + + assert attrs["temperature"] == 25.0 + + await hass.services.async_call( + "climate", + "set_preset_mode", + {"entity_id": "climate.anna", "preset_mode": "away"}, + blocking=True, + ) + + state = hass.states.get("climate.anna") + attrs = state.attributes + + assert attrs["preset_mode"] == "away" + + await hass.services.async_call( + "climate", + "set_hvac_mode", + {"entity_id": "climate.anna", "hvac_mode": "heat_cool"}, + blocking=True, + ) + + state = hass.states.get("climate.anna") + attrs = state.attributes + + assert state.state == "heat_cool" diff --git a/tests/components/plugwise/test_config_flow.py b/tests/components/plugwise/test_config_flow.py index 11c0000977a..219ba8aee7f 100644 --- a/tests/components/plugwise/test_config_flow.py +++ b/tests/components/plugwise/test_config_flow.py @@ -62,14 +62,14 @@ async def test_form(hass): {"host": TEST_HOST, "password": TEST_PASSWORD}, ) + await hass.async_block_till_done() + assert result2["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY assert result2["data"] == { "host": TEST_HOST, "password": TEST_PASSWORD, } - await hass.async_block_till_done() - assert result["errors"] == {} assert len(mock_setup.mock_calls) == 1 assert len(mock_setup_entry.mock_calls) == 1 @@ -108,7 +108,6 @@ async def test_zeroconf_form(hass): "password": TEST_PASSWORD, } - assert result["errors"] == {} assert len(mock_setup.mock_calls) == 1 assert len(mock_setup_entry.mock_calls) == 1 diff --git a/tests/components/plugwise/test_init.py b/tests/components/plugwise/test_init.py new file mode 100644 index 00000000000..713cd4930d7 --- /dev/null +++ b/tests/components/plugwise/test_init.py @@ -0,0 +1,45 @@ +"""Tests for the Plugwise Climate integration.""" + +import asyncio + +from Plugwise_Smile.Smile import Smile + +from homeassistant.config_entries import ( + ENTRY_STATE_SETUP_ERROR, + ENTRY_STATE_SETUP_RETRY, +) + +from tests.components.plugwise.common import async_init_integration + + +async def test_smile_unauthorized(hass, mock_smile_unauth): + """Test failing unauthorization by Smile.""" + entry = await async_init_integration(hass, mock_smile_unauth) + assert entry.state == ENTRY_STATE_SETUP_ERROR + + +async def test_smile_error(hass, mock_smile_error): + """Test server error handling by Smile.""" + entry = await async_init_integration(hass, mock_smile_error) + assert entry.state == ENTRY_STATE_SETUP_RETRY + + +async def test_smile_notconnect(hass, mock_smile_notconnect): + """Connection failure error handling by Smile.""" + mock_smile_notconnect.connect.return_value = False + entry = await async_init_integration(hass, mock_smile_notconnect) + assert entry.state == ENTRY_STATE_SETUP_RETRY + + +async def test_smile_timeout(hass, mock_smile_notconnect): + """Timeout error handling by Smile.""" + mock_smile_notconnect.connect.side_effect = asyncio.TimeoutError + entry = await async_init_integration(hass, mock_smile_notconnect) + assert entry.state == ENTRY_STATE_SETUP_RETRY + + +async def test_smile_adam_xmlerror(hass, mock_smile_adam): + """Detect malformed XML by Smile in Adam environment.""" + mock_smile_adam.full_update_device.side_effect = Smile.XMLDataMissingError + entry = await async_init_integration(hass, mock_smile_adam) + assert entry.state == ENTRY_STATE_SETUP_RETRY diff --git a/tests/components/plugwise/test_sensor.py b/tests/components/plugwise/test_sensor.py new file mode 100644 index 00000000000..bc586120517 --- /dev/null +++ b/tests/components/plugwise/test_sensor.py @@ -0,0 +1,66 @@ +"""Tests for the Plugwise Sensor integration.""" + +from homeassistant.config_entries import ENTRY_STATE_LOADED + +from tests.components.plugwise.common import async_init_integration + + +async def test_adam_climate_sensor_entities(hass, mock_smile_adam): + """Test creation of climate related sensor entities.""" + entry = await async_init_integration(hass, mock_smile_adam) + assert entry.state == ENTRY_STATE_LOADED + + state = hass.states.get("sensor.adam_outdoor_temperature") + assert float(state.state) == 7.81 + + state = hass.states.get("sensor.cv_pomp_electricity_consumed") + assert float(state.state) == 35.6 + + state = hass.states.get("sensor.auxiliary_water_temperature") + assert float(state.state) == 70.0 + + state = hass.states.get("sensor.cv_pomp_electricity_consumed_interval") + assert float(state.state) == 7.37 + + await hass.helpers.entity_component.async_update_entity( + "sensor.zone_lisa_wk_battery" + ) + + state = hass.states.get("sensor.zone_lisa_wk_battery") + assert float(state.state) == 34 + + +async def test_anna_climate_sensor_entities(hass, mock_smile_anna): + """Test creation of climate related sensor entities.""" + entry = await async_init_integration(hass, mock_smile_anna) + assert entry.state == ENTRY_STATE_LOADED + + state = hass.states.get("sensor.auxiliary_outdoor_temperature") + assert float(state.state) == 18.0 + + state = hass.states.get("sensor.auxiliary_water_temperature") + assert float(state.state) == 29.1 + + state = hass.states.get("sensor.anna_illuminance") + assert float(state.state) == 86.0 + + +async def test_p1_dsmr_sensor_entities(hass, mock_smile_p1): + """Test creation of power related sensor entities.""" + entry = await async_init_integration(hass, mock_smile_p1) + assert entry.state == ENTRY_STATE_LOADED + + state = hass.states.get("sensor.p1_net_electricity_point") + assert float(state.state) == -2761.0 + + state = hass.states.get("sensor.p1_electricity_consumed_off_peak_cumulative") + assert int(state.state) == 551 + + state = hass.states.get("sensor.p1_electricity_produced_peak_point") + assert float(state.state) == 2761.0 + + state = hass.states.get("sensor.p1_electricity_consumed_peak_cumulative") + assert int(state.state) == 442 + + state = hass.states.get("sensor.p1_gas_consumed_cumulative") + assert float(state.state) == 584.9 diff --git a/tests/components/plugwise/test_switch.py b/tests/components/plugwise/test_switch.py new file mode 100644 index 00000000000..a58ebf83caa --- /dev/null +++ b/tests/components/plugwise/test_switch.py @@ -0,0 +1,50 @@ +"""Tests for the Plugwise switch integration.""" + +from homeassistant.config_entries import ENTRY_STATE_LOADED + +from tests.components.plugwise.common import async_init_integration + + +async def test_adam_climate_switch_entities(hass, mock_smile_adam): + """Test creation of climate related switch entities.""" + entry = await async_init_integration(hass, mock_smile_adam) + assert entry.state == ENTRY_STATE_LOADED + + state = hass.states.get("switch.cv_pomp") + assert str(state.state) == "on" + + state = hass.states.get("switch.fibaro_hc2") + assert str(state.state) == "on" + + +async def test_adam_climate_switch_changes(hass, mock_smile_adam): + """Test changing of climate related switch entities.""" + entry = await async_init_integration(hass, mock_smile_adam) + assert entry.state == ENTRY_STATE_LOADED + + await hass.services.async_call( + "switch", + "turn_off", + {"entity_id": "switch.cv_pomp"}, + blocking=True, + ) + state = hass.states.get("switch.cv_pomp") + assert str(state.state) == "off" + + await hass.services.async_call( + "switch", + "toggle", + {"entity_id": "switch.fibaro_hc2"}, + blocking=True, + ) + state = hass.states.get("switch.fibaro_hc2") + assert str(state.state) == "off" + + await hass.services.async_call( + "switch", + "toggle", + {"entity_id": "switch.fibaro_hc2"}, + blocking=True, + ) + state = hass.states.get("switch.fibaro_hc2") + assert str(state.state) == "on" diff --git a/tests/fixtures/plugwise/adam_multiple_devices_per_zone/get_all_devices.json b/tests/fixtures/plugwise/adam_multiple_devices_per_zone/get_all_devices.json new file mode 100644 index 00000000000..61ebc4d9a6c --- /dev/null +++ b/tests/fixtures/plugwise/adam_multiple_devices_per_zone/get_all_devices.json @@ -0,0 +1 @@ +{"df4a4a8169904cdb9c03d61a21f42140": {"name": "Zone Lisa Bios", "types": {"py/set": ["thermostat"]}, "class": "zone_thermostat", "location": "12493538af164a409c6a1c79e38afe1c"}, "b310b72a0e354bfab43089919b9a88bf": {"name": "Floor kraan", "types": {"py/set": ["thermostat"]}, "class": "thermo_sensor", "location": "c50f167537524366a5af7aa3942feb1e"}, "a2c3583e0a6349358998b760cea82d2a": {"name": "Bios Cv Thermostatic Radiator ", "types": {"py/set": ["thermostat"]}, "class": "thermo_sensor", "location": "12493538af164a409c6a1c79e38afe1c"}, "b59bcebaf94b499ea7d46e4a66fb62d8": {"name": "Zone Lisa WK", "types": {"py/set": ["thermostat"]}, "class": "zone_thermostat", "location": "c50f167537524366a5af7aa3942feb1e"}, "fe799307f1624099878210aa0b9f1475": {"name": "Adam", "types": {"py/set": ["temperature", "thermostat", "home"]}, "class": "gateway", "location": "1f9dcf83fd4e4b66b72ff787957bfe5d"}, "d3da73bde12a47d5a6b8f9dad971f2ec": {"name": "Thermostatic Radiator Jessie", "types": {"py/set": ["thermostat"]}, "class": "thermo_sensor", "location": "82fa13f017d240daa0d0ea1775420f24"}, "21f2b542c49845e6bb416884c55778d6": {"name": "Playstation Smart Plug", "types": {"py/set": ["plug", "power"]}, "class": "game_console", "location": "cd143c07248f491493cea0533bc3d669"}, "78d1126fc4c743db81b61c20e88342a7": {"name": "CV Pomp", "types": {"py/set": ["plug", "power"]}, "class": "central_heating_pump", "location": "c50f167537524366a5af7aa3942feb1e"}, "90986d591dcd426cae3ec3e8111ff730": {"name": "Adam", "types": {"py/set": ["temperature", "thermostat", "home"]}, "class": "heater_central", "location": "1f9dcf83fd4e4b66b72ff787957bfe5d"}, "cd0ddb54ef694e11ac18ed1cbce5dbbd": {"name": "NAS", "types": {"py/set": ["plug", "power"]}, "class": "vcr", "location": "cd143c07248f491493cea0533bc3d669"}, "4a810418d5394b3f82727340b91ba740": {"name": "USG Smart Plug", "types": {"py/set": ["plug", "power"]}, "class": "router", "location": "cd143c07248f491493cea0533bc3d669"}, "02cf28bfec924855854c544690a609ef": {"name": "NVR", "types": {"py/set": ["plug", "power"]}, "class": "vcr", "location": "cd143c07248f491493cea0533bc3d669"}, "a28f588dc4a049a483fd03a30361ad3a": {"name": "Fibaro HC2", "types": {"py/set": ["plug", "power"]}, "class": "settop", "location": "cd143c07248f491493cea0533bc3d669"}, "6a3bf693d05e48e0b460c815a4fdd09d": {"name": "Zone Thermostat Jessie", "types": {"py/set": ["thermostat"]}, "class": "zone_thermostat", "location": "82fa13f017d240daa0d0ea1775420f24"}, "680423ff840043738f42cc7f1ff97a36": {"name": "Thermostatic Radiator Badkamer", "types": {"py/set": ["thermostat"]}, "class": "thermo_sensor", "location": "08963fec7c53423ca5680aa4cb502c63"}, "f1fee6043d3642a9b0a65297455f008e": {"name": "Zone Thermostat Badkamer", "types": {"py/set": ["thermostat"]}, "class": "zone_thermostat", "location": "08963fec7c53423ca5680aa4cb502c63"}, "675416a629f343c495449970e2ca37b5": {"name": "Ziggo Modem", "types": {"py/set": ["plug", "power"]}, "class": "router", "location": "cd143c07248f491493cea0533bc3d669"}, "e7693eb9582644e5b865dba8d4447cf1": {"name": "CV Kraan Garage", "types": {"py/set": ["thermostat"]}, "class": "thermostatic_radiator_valve", "location": "446ac08dd04d4eff8ac57489757b7314"}} \ No newline at end of file diff --git a/tests/fixtures/plugwise/adam_multiple_devices_per_zone/get_device_data/02cf28bfec924855854c544690a609ef.json b/tests/fixtures/plugwise/adam_multiple_devices_per_zone/get_device_data/02cf28bfec924855854c544690a609ef.json new file mode 100644 index 00000000000..238da9d846a --- /dev/null +++ b/tests/fixtures/plugwise/adam_multiple_devices_per_zone/get_device_data/02cf28bfec924855854c544690a609ef.json @@ -0,0 +1 @@ +{"electricity_consumed": 34.0, "electricity_consumed_interval": 9.15, "electricity_produced": 0.0, "electricity_produced_interval": 0.0, "relay": true} \ No newline at end of file diff --git a/tests/fixtures/plugwise/adam_multiple_devices_per_zone/get_device_data/21f2b542c49845e6bb416884c55778d6.json b/tests/fixtures/plugwise/adam_multiple_devices_per_zone/get_device_data/21f2b542c49845e6bb416884c55778d6.json new file mode 100644 index 00000000000..4fcb40c4cf8 --- /dev/null +++ b/tests/fixtures/plugwise/adam_multiple_devices_per_zone/get_device_data/21f2b542c49845e6bb416884c55778d6.json @@ -0,0 +1 @@ +{"electricity_consumed": 82.6, "electricity_consumed_interval": 8.6, "electricity_produced": 0.0, "electricity_produced_interval": 0.0, "relay": true} \ No newline at end of file diff --git a/tests/fixtures/plugwise/adam_multiple_devices_per_zone/get_device_data/4a810418d5394b3f82727340b91ba740.json b/tests/fixtures/plugwise/adam_multiple_devices_per_zone/get_device_data/4a810418d5394b3f82727340b91ba740.json new file mode 100644 index 00000000000..feb6290c9c4 --- /dev/null +++ b/tests/fixtures/plugwise/adam_multiple_devices_per_zone/get_device_data/4a810418d5394b3f82727340b91ba740.json @@ -0,0 +1 @@ +{"electricity_consumed": 8.5, "electricity_consumed_interval": 0.0, "electricity_produced": 0.0, "electricity_produced_interval": 0.0, "relay": true} \ No newline at end of file diff --git a/tests/fixtures/plugwise/adam_multiple_devices_per_zone/get_device_data/675416a629f343c495449970e2ca37b5.json b/tests/fixtures/plugwise/adam_multiple_devices_per_zone/get_device_data/675416a629f343c495449970e2ca37b5.json new file mode 100644 index 00000000000..74d15fac374 --- /dev/null +++ b/tests/fixtures/plugwise/adam_multiple_devices_per_zone/get_device_data/675416a629f343c495449970e2ca37b5.json @@ -0,0 +1 @@ +{"electricity_consumed": 12.2, "electricity_consumed_interval": 2.97, "electricity_produced": 0.0, "electricity_produced_interval": 0.0, "relay": true} \ No newline at end of file diff --git a/tests/fixtures/plugwise/adam_multiple_devices_per_zone/get_device_data/680423ff840043738f42cc7f1ff97a36.json b/tests/fixtures/plugwise/adam_multiple_devices_per_zone/get_device_data/680423ff840043738f42cc7f1ff97a36.json new file mode 100644 index 00000000000..75bc62fbad4 --- /dev/null +++ b/tests/fixtures/plugwise/adam_multiple_devices_per_zone/get_device_data/680423ff840043738f42cc7f1ff97a36.json @@ -0,0 +1 @@ +{"setpoint": 14.0, "temperature": 19.1, "battery": 0.51, "valve_position": 0.0, "temperature_difference": -0.4} \ No newline at end of file diff --git a/tests/fixtures/plugwise/adam_multiple_devices_per_zone/get_device_data/6a3bf693d05e48e0b460c815a4fdd09d.json b/tests/fixtures/plugwise/adam_multiple_devices_per_zone/get_device_data/6a3bf693d05e48e0b460c815a4fdd09d.json new file mode 100644 index 00000000000..41333f374e1 --- /dev/null +++ b/tests/fixtures/plugwise/adam_multiple_devices_per_zone/get_device_data/6a3bf693d05e48e0b460c815a4fdd09d.json @@ -0,0 +1 @@ +{"setpoint": 15.0, "temperature": 17.2, "battery": 0.37, "active_preset": "asleep", "presets": {"home": [20.0, 22.0], "no_frost": [10.0, 30.0], "away": [12.0, 25.0], "vacation": [11.0, 28.0], "asleep": [16.0, 24.0]}, "schedule_temperature": 15.0, "available_schedules": ["CV Jessie"], "selected_schedule": "CV Jessie", "last_used": "CV Jessie"} \ No newline at end of file diff --git a/tests/fixtures/plugwise/adam_multiple_devices_per_zone/get_device_data/78d1126fc4c743db81b61c20e88342a7.json b/tests/fixtures/plugwise/adam_multiple_devices_per_zone/get_device_data/78d1126fc4c743db81b61c20e88342a7.json new file mode 100644 index 00000000000..7a9c3e9be01 --- /dev/null +++ b/tests/fixtures/plugwise/adam_multiple_devices_per_zone/get_device_data/78d1126fc4c743db81b61c20e88342a7.json @@ -0,0 +1 @@ +{"electricity_consumed": 35.6, "electricity_consumed_interval": 7.37, "electricity_produced": 0.0, "electricity_produced_interval": 0.0, "relay": true} \ No newline at end of file diff --git a/tests/fixtures/plugwise/adam_multiple_devices_per_zone/get_device_data/90986d591dcd426cae3ec3e8111ff730.json b/tests/fixtures/plugwise/adam_multiple_devices_per_zone/get_device_data/90986d591dcd426cae3ec3e8111ff730.json new file mode 100644 index 00000000000..5e481d36b46 --- /dev/null +++ b/tests/fixtures/plugwise/adam_multiple_devices_per_zone/get_device_data/90986d591dcd426cae3ec3e8111ff730.json @@ -0,0 +1 @@ +{"water_temperature": 70.0, "intended_boiler_temperature": 70.0, "modulation_level": 0.01} \ No newline at end of file diff --git a/tests/fixtures/plugwise/adam_multiple_devices_per_zone/get_device_data/a28f588dc4a049a483fd03a30361ad3a.json b/tests/fixtures/plugwise/adam_multiple_devices_per_zone/get_device_data/a28f588dc4a049a483fd03a30361ad3a.json new file mode 100644 index 00000000000..0aeca4cc18e --- /dev/null +++ b/tests/fixtures/plugwise/adam_multiple_devices_per_zone/get_device_data/a28f588dc4a049a483fd03a30361ad3a.json @@ -0,0 +1 @@ +{"electricity_consumed": 12.5, "electricity_consumed_interval": 3.8, "electricity_produced": 0.0, "electricity_produced_interval": 0.0, "relay": true} \ No newline at end of file diff --git a/tests/fixtures/plugwise/adam_multiple_devices_per_zone/get_device_data/a2c3583e0a6349358998b760cea82d2a.json b/tests/fixtures/plugwise/adam_multiple_devices_per_zone/get_device_data/a2c3583e0a6349358998b760cea82d2a.json new file mode 100644 index 00000000000..eef83a67a20 --- /dev/null +++ b/tests/fixtures/plugwise/adam_multiple_devices_per_zone/get_device_data/a2c3583e0a6349358998b760cea82d2a.json @@ -0,0 +1 @@ +{"setpoint": 13.0, "temperature": 17.2, "battery": 0.62, "valve_position": 0.0, "temperature_difference": -0.2} \ No newline at end of file diff --git a/tests/fixtures/plugwise/adam_multiple_devices_per_zone/get_device_data/b310b72a0e354bfab43089919b9a88bf.json b/tests/fixtures/plugwise/adam_multiple_devices_per_zone/get_device_data/b310b72a0e354bfab43089919b9a88bf.json new file mode 100644 index 00000000000..16da5f44ef5 --- /dev/null +++ b/tests/fixtures/plugwise/adam_multiple_devices_per_zone/get_device_data/b310b72a0e354bfab43089919b9a88bf.json @@ -0,0 +1 @@ +{"setpoint": 21.5, "temperature": 26.0, "valve_position": 1.0, "temperature_difference": 3.5} \ No newline at end of file diff --git a/tests/fixtures/plugwise/adam_multiple_devices_per_zone/get_device_data/b59bcebaf94b499ea7d46e4a66fb62d8.json b/tests/fixtures/plugwise/adam_multiple_devices_per_zone/get_device_data/b59bcebaf94b499ea7d46e4a66fb62d8.json new file mode 100644 index 00000000000..65fa0dd3d52 --- /dev/null +++ b/tests/fixtures/plugwise/adam_multiple_devices_per_zone/get_device_data/b59bcebaf94b499ea7d46e4a66fb62d8.json @@ -0,0 +1 @@ +{"setpoint": 21.5, "temperature": 20.9, "battery": 0.34, "active_preset": "home", "presets": {"vacation": [15.0, 28.0], "asleep": [18.0, 24.0], "no_frost": [12.0, 30.0], "away": [17.0, 25.0], "home": [21.5, 22.0]}, "schedule_temperature": 21.5, "available_schedules": ["GF7 Woonkamer"], "selected_schedule": "GF7 Woonkamer", "last_used": "GF7 Woonkamer"} \ No newline at end of file diff --git a/tests/fixtures/plugwise/adam_multiple_devices_per_zone/get_device_data/cd0ddb54ef694e11ac18ed1cbce5dbbd.json b/tests/fixtures/plugwise/adam_multiple_devices_per_zone/get_device_data/cd0ddb54ef694e11ac18ed1cbce5dbbd.json new file mode 100644 index 00000000000..fbefc5bba25 --- /dev/null +++ b/tests/fixtures/plugwise/adam_multiple_devices_per_zone/get_device_data/cd0ddb54ef694e11ac18ed1cbce5dbbd.json @@ -0,0 +1 @@ +{"electricity_consumed": 16.5, "electricity_consumed_interval": 0.5, "electricity_produced": 0.0, "electricity_produced_interval": 0.0, "relay": true} \ No newline at end of file diff --git a/tests/fixtures/plugwise/adam_multiple_devices_per_zone/get_device_data/d3da73bde12a47d5a6b8f9dad971f2ec.json b/tests/fixtures/plugwise/adam_multiple_devices_per_zone/get_device_data/d3da73bde12a47d5a6b8f9dad971f2ec.json new file mode 100644 index 00000000000..fd202e05586 --- /dev/null +++ b/tests/fixtures/plugwise/adam_multiple_devices_per_zone/get_device_data/d3da73bde12a47d5a6b8f9dad971f2ec.json @@ -0,0 +1 @@ +{"setpoint": 15.0, "temperature": 17.1, "battery": 0.62, "valve_position": 0.0, "temperature_difference": 0.1} \ No newline at end of file diff --git a/tests/fixtures/plugwise/adam_multiple_devices_per_zone/get_device_data/df4a4a8169904cdb9c03d61a21f42140.json b/tests/fixtures/plugwise/adam_multiple_devices_per_zone/get_device_data/df4a4a8169904cdb9c03d61a21f42140.json new file mode 100644 index 00000000000..12947c42ce0 --- /dev/null +++ b/tests/fixtures/plugwise/adam_multiple_devices_per_zone/get_device_data/df4a4a8169904cdb9c03d61a21f42140.json @@ -0,0 +1 @@ +{"setpoint": 13.0, "temperature": 16.5, "battery": 0.67, "active_preset": "away", "presets": {"home": [20.0, 22.0], "away": [12.0, 25.0], "vacation": [12.0, 28.0], "no_frost": [8.0, 30.0], "asleep": [15.0, 24.0]}, "schedule_temperature": null, "available_schedules": [], "selected_schedule": null, "last_used": null} \ No newline at end of file diff --git a/tests/fixtures/plugwise/adam_multiple_devices_per_zone/get_device_data/e7693eb9582644e5b865dba8d4447cf1.json b/tests/fixtures/plugwise/adam_multiple_devices_per_zone/get_device_data/e7693eb9582644e5b865dba8d4447cf1.json new file mode 100644 index 00000000000..151b4b41f70 --- /dev/null +++ b/tests/fixtures/plugwise/adam_multiple_devices_per_zone/get_device_data/e7693eb9582644e5b865dba8d4447cf1.json @@ -0,0 +1 @@ +{"setpoint": 5.5, "temperature": 15.6, "battery": 0.68, "valve_position": 0.0, "temperature_difference": 0.0, "active_preset": "no_frost", "presets": {"home": [20.0, 22.0], "asleep": [17.0, 24.0], "away": [15.0, 25.0], "vacation": [15.0, 28.0], "no_frost": [10.0, 30.0]}, "schedule_temperature": null, "available_schedules": [], "selected_schedule": null, "last_used": null} \ No newline at end of file diff --git a/tests/fixtures/plugwise/adam_multiple_devices_per_zone/get_device_data/f1fee6043d3642a9b0a65297455f008e.json b/tests/fixtures/plugwise/adam_multiple_devices_per_zone/get_device_data/f1fee6043d3642a9b0a65297455f008e.json new file mode 100644 index 00000000000..9934e109033 --- /dev/null +++ b/tests/fixtures/plugwise/adam_multiple_devices_per_zone/get_device_data/f1fee6043d3642a9b0a65297455f008e.json @@ -0,0 +1 @@ +{"setpoint": 14.0, "temperature": 18.9, "battery": 0.92, "active_preset": "away", "presets": {"asleep": [17.0, 24.0], "no_frost": [10.0, 30.0], "away": [14.0, 25.0], "home": [21.0, 22.0], "vacation": [12.0, 28.0]}, "schedule_temperature": 14.0, "available_schedules": ["Badkamer Schema"], "selected_schedule": "Badkamer Schema", "last_used": "Badkamer Schema"} \ No newline at end of file diff --git a/tests/fixtures/plugwise/adam_multiple_devices_per_zone/get_device_data/fe799307f1624099878210aa0b9f1475.json b/tests/fixtures/plugwise/adam_multiple_devices_per_zone/get_device_data/fe799307f1624099878210aa0b9f1475.json new file mode 100644 index 00000000000..ef325af7bc2 --- /dev/null +++ b/tests/fixtures/plugwise/adam_multiple_devices_per_zone/get_device_data/fe799307f1624099878210aa0b9f1475.json @@ -0,0 +1 @@ +{"outdoor_temperature": 7.81} \ No newline at end of file diff --git a/tests/fixtures/plugwise/anna_heatpump/get_all_devices.json b/tests/fixtures/plugwise/anna_heatpump/get_all_devices.json new file mode 100644 index 00000000000..4992a175b14 --- /dev/null +++ b/tests/fixtures/plugwise/anna_heatpump/get_all_devices.json @@ -0,0 +1 @@ +{"1cbf783bb11e4a7c8a6843dee3a86927": {"name": "Anna", "types": {"py/set": ["temperature", "thermostat", "home"]}, "class": "heater_central", "location": "a57efe5f145f498c9be62a9b63626fbf"}, "015ae9ea3f964e668e490fa39da3870b": {"name": "Anna", "types": {"py/set": ["temperature", "thermostat", "home"]}, "class": "gateway", "location": "a57efe5f145f498c9be62a9b63626fbf"}, "3cb70739631c4d17a86b8b12e8a5161b": {"name": "Anna", "types": {"py/set": ["thermostat"]}, "class": "thermostat", "location": "c784ee9fdab44e1395b8dee7d7a497d5"}} \ No newline at end of file diff --git a/tests/fixtures/plugwise/anna_heatpump/get_device_data/015ae9ea3f964e668e490fa39da3870b.json b/tests/fixtures/plugwise/anna_heatpump/get_device_data/015ae9ea3f964e668e490fa39da3870b.json new file mode 100644 index 00000000000..750aa8b455c --- /dev/null +++ b/tests/fixtures/plugwise/anna_heatpump/get_device_data/015ae9ea3f964e668e490fa39da3870b.json @@ -0,0 +1 @@ +{"outdoor_temperature": 20.2} \ No newline at end of file diff --git a/tests/fixtures/plugwise/anna_heatpump/get_device_data/1cbf783bb11e4a7c8a6843dee3a86927.json b/tests/fixtures/plugwise/anna_heatpump/get_device_data/1cbf783bb11e4a7c8a6843dee3a86927.json new file mode 100644 index 00000000000..a8aea8e1357 --- /dev/null +++ b/tests/fixtures/plugwise/anna_heatpump/get_device_data/1cbf783bb11e4a7c8a6843dee3a86927.json @@ -0,0 +1 @@ +{"outdoor_temperature": 18.0, "heating_state": false, "dhw_state": false, "water_temperature": 29.1, "return_temperature": 25.1, "water_pressure": 1.57, "intended_boiler_temperature": 0.0, "modulation_level": 0.52, "cooling_state": false, "slave_boiler_state": false, "compressor_state": true, "flame_state": false} \ No newline at end of file diff --git a/tests/fixtures/plugwise/anna_heatpump/get_device_data/3cb70739631c4d17a86b8b12e8a5161b.json b/tests/fixtures/plugwise/anna_heatpump/get_device_data/3cb70739631c4d17a86b8b12e8a5161b.json new file mode 100644 index 00000000000..2a092e792d5 --- /dev/null +++ b/tests/fixtures/plugwise/anna_heatpump/get_device_data/3cb70739631c4d17a86b8b12e8a5161b.json @@ -0,0 +1 @@ +{"setpoint": 21.0, "temperature": 23.3, "active_preset": "home", "presets": {"no_frost": [10.0, 30.0], "home": [21.0, 22.0], "away": [20.0, 25.0], "asleep": [20.5, 24.0], "vacation": [17.0, 28.0]}, "schedule_temperature": null, "available_schedules": ["standaard"], "selected_schedule": "standaard", "last_used": "standaard", "illuminance": 86.0} \ No newline at end of file diff --git a/tests/fixtures/plugwise/p1v3_full_option/get_all_devices.json b/tests/fixtures/plugwise/p1v3_full_option/get_all_devices.json new file mode 100644 index 00000000000..e25fcb953c8 --- /dev/null +++ b/tests/fixtures/plugwise/p1v3_full_option/get_all_devices.json @@ -0,0 +1 @@ +{"e950c7d5e1ee407a858e2a8b5016c8b3": {"name": "P1", "types": {"py/set": ["power", "home"]}, "class": "gateway", "location": "cd3e822288064775a7c4afcdd70bdda2"}} \ No newline at end of file diff --git a/tests/fixtures/plugwise/p1v3_full_option/get_device_data/e950c7d5e1ee407a858e2a8b5016c8b3.json b/tests/fixtures/plugwise/p1v3_full_option/get_device_data/e950c7d5e1ee407a858e2a8b5016c8b3.json new file mode 100644 index 00000000000..36cb66c7902 --- /dev/null +++ b/tests/fixtures/plugwise/p1v3_full_option/get_device_data/e950c7d5e1ee407a858e2a8b5016c8b3.json @@ -0,0 +1 @@ +{"net_electricity_point": -2761.0, "electricity_consumed_peak_point": 0.0, "electricity_consumed_off_peak_point": 0.0, "net_electricity_cumulative": 442972.0, "electricity_consumed_peak_cumulative": 442932.0, "electricity_consumed_off_peak_cumulative": 551090.0, "net_electricity_interval": 0.0, "electricity_consumed_peak_interval": 0.0, "electricity_consumed_off_peak_interval": 0.0, "electricity_produced_peak_point": 2761.0, "electricity_produced_off_peak_point": 0.0, "electricity_produced_peak_cumulative": 396559.0, "electricity_produced_off_peak_cumulative": 154491.0, "electricity_produced_peak_interval": 0.0, "electricity_produced_off_peak_interval": 0.0, "gas_consumed_cumulative": 584.9, "gas_consumed_interval": 0.0} \ No newline at end of file