Add tests for Plugwise integration (#36371)
parent
07d5af1969
commit
bb9ea7ce6e
|
@ -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/*
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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"
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
|
@ -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
|
|
@ -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"
|
|
@ -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"}}
|
|
@ -0,0 +1 @@
|
|||
{"electricity_consumed": 34.0, "electricity_consumed_interval": 9.15, "electricity_produced": 0.0, "electricity_produced_interval": 0.0, "relay": true}
|
|
@ -0,0 +1 @@
|
|||
{"electricity_consumed": 82.6, "electricity_consumed_interval": 8.6, "electricity_produced": 0.0, "electricity_produced_interval": 0.0, "relay": true}
|
|
@ -0,0 +1 @@
|
|||
{"electricity_consumed": 8.5, "electricity_consumed_interval": 0.0, "electricity_produced": 0.0, "electricity_produced_interval": 0.0, "relay": true}
|
|
@ -0,0 +1 @@
|
|||
{"electricity_consumed": 12.2, "electricity_consumed_interval": 2.97, "electricity_produced": 0.0, "electricity_produced_interval": 0.0, "relay": true}
|
|
@ -0,0 +1 @@
|
|||
{"setpoint": 14.0, "temperature": 19.1, "battery": 0.51, "valve_position": 0.0, "temperature_difference": -0.4}
|
|
@ -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"}
|
|
@ -0,0 +1 @@
|
|||
{"electricity_consumed": 35.6, "electricity_consumed_interval": 7.37, "electricity_produced": 0.0, "electricity_produced_interval": 0.0, "relay": true}
|
|
@ -0,0 +1 @@
|
|||
{"water_temperature": 70.0, "intended_boiler_temperature": 70.0, "modulation_level": 0.01}
|
|
@ -0,0 +1 @@
|
|||
{"electricity_consumed": 12.5, "electricity_consumed_interval": 3.8, "electricity_produced": 0.0, "electricity_produced_interval": 0.0, "relay": true}
|
|
@ -0,0 +1 @@
|
|||
{"setpoint": 13.0, "temperature": 17.2, "battery": 0.62, "valve_position": 0.0, "temperature_difference": -0.2}
|
|
@ -0,0 +1 @@
|
|||
{"setpoint": 21.5, "temperature": 26.0, "valve_position": 1.0, "temperature_difference": 3.5}
|
|
@ -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"}
|
|
@ -0,0 +1 @@
|
|||
{"electricity_consumed": 16.5, "electricity_consumed_interval": 0.5, "electricity_produced": 0.0, "electricity_produced_interval": 0.0, "relay": true}
|
|
@ -0,0 +1 @@
|
|||
{"setpoint": 15.0, "temperature": 17.1, "battery": 0.62, "valve_position": 0.0, "temperature_difference": 0.1}
|
|
@ -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}
|
|
@ -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}
|
|
@ -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"}
|
|
@ -0,0 +1 @@
|
|||
{"outdoor_temperature": 7.81}
|
|
@ -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"}}
|
1
tests/fixtures/plugwise/anna_heatpump/get_device_data/015ae9ea3f964e668e490fa39da3870b.json
vendored
Normal file
1
tests/fixtures/plugwise/anna_heatpump/get_device_data/015ae9ea3f964e668e490fa39da3870b.json
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
{"outdoor_temperature": 20.2}
|
1
tests/fixtures/plugwise/anna_heatpump/get_device_data/1cbf783bb11e4a7c8a6843dee3a86927.json
vendored
Normal file
1
tests/fixtures/plugwise/anna_heatpump/get_device_data/1cbf783bb11e4a7c8a6843dee3a86927.json
vendored
Normal file
|
@ -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}
|
1
tests/fixtures/plugwise/anna_heatpump/get_device_data/3cb70739631c4d17a86b8b12e8a5161b.json
vendored
Normal file
1
tests/fixtures/plugwise/anna_heatpump/get_device_data/3cb70739631c4d17a86b8b12e8a5161b.json
vendored
Normal file
|
@ -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}
|
|
@ -0,0 +1 @@
|
|||
{"e950c7d5e1ee407a858e2a8b5016c8b3": {"name": "P1", "types": {"py/set": ["power", "home"]}, "class": "gateway", "location": "cd3e822288064775a7c4afcdd70bdda2"}}
|
|
@ -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}
|
Loading…
Reference in New Issue