init home-assistant

This commit is contained in:
2026-11-19 15:15:32 -05:00
parent 2e81d9d300
commit feec6ef9fb
19230 changed files with 3335526 additions and 0 deletions

View File

@@ -0,0 +1 @@
"""Tests for the Plugwise integration."""

View File

@@ -0,0 +1,381 @@
"""Setup mocks for the Plugwise integration tests."""
from __future__ import annotations
from collections.abc import Generator
import json
from typing import Any
from unittest.mock import AsyncMock, MagicMock, patch
from packaging.version import Version
from plugwise import PlugwiseData
import pytest
from homeassistant.components.plugwise.const import DOMAIN
from homeassistant.const import (
CONF_HOST,
CONF_MAC,
CONF_PASSWORD,
CONF_PORT,
CONF_USERNAME,
)
from homeassistant.core import HomeAssistant
from tests.common import MockConfigEntry, load_fixture
def _read_json(environment: str, call: str) -> dict[str, Any]:
"""Undecode the json data."""
fixture = load_fixture(f"plugwise/{environment}/{call}.json")
return json.loads(fixture)
@pytest.fixture
def mock_config_entry() -> MockConfigEntry:
"""Return the default mocked config entry."""
return MockConfigEntry(
title="My Plugwise",
domain=DOMAIN,
data={
CONF_HOST: "127.0.0.1",
CONF_MAC: "AA:BB:CC:DD:EE:FF",
CONF_PASSWORD: "test-password",
CONF_PORT: 80,
CONF_USERNAME: "smile",
},
unique_id="smile98765",
)
@pytest.fixture
def mock_setup_entry() -> Generator[AsyncMock]:
"""Mock setting up a config entry."""
with patch(
"homeassistant.components.plugwise.async_setup_entry", return_value=True
) as mock_setup:
yield mock_setup
@pytest.fixture
def mock_smile_config_flow() -> Generator[MagicMock]:
"""Return a mocked Smile client."""
with patch(
"homeassistant.components.plugwise.config_flow.Smile",
autospec=True,
) as smile_mock:
smile = smile_mock.return_value
smile.smile_hostname = "smile12345"
smile.smile_model = "Test Model"
smile.smile_model_id = "Test Model ID"
smile.smile_name = "Test Smile Name"
smile.connect.return_value = Version("4.3.2")
yield smile
@pytest.fixture
def mock_smile_adam() -> Generator[MagicMock]:
"""Create a Mock Adam environment for testing exceptions."""
chosen_env = "m_adam_multiple_devices_per_zone"
with (
patch(
"homeassistant.components.plugwise.coordinator.Smile", autospec=True
) as smile_mock,
patch(
"homeassistant.components.plugwise.config_flow.Smile",
new=smile_mock,
),
):
smile = smile_mock.return_value
smile.gateway_id = "fe799307f1624099878210aa0b9f1475"
smile.heater_id = "90986d591dcd426cae3ec3e8111ff730"
smile.smile_version = "3.0.15"
smile.smile_type = "thermostat"
smile.smile_hostname = "smile98765"
smile.smile_model = "Gateway"
smile.smile_model_id = "smile_open_therm"
smile.smile_name = "Adam"
smile.connect.return_value = Version("3.0.15")
all_data = _read_json(chosen_env, "all_data")
smile.async_update.return_value = PlugwiseData(
all_data["devices"], all_data["gateway"]
)
yield smile
@pytest.fixture
def mock_smile_adam_2() -> Generator[MagicMock]:
"""Create a 2nd Mock Adam environment for testing exceptions."""
chosen_env = "m_adam_heating"
with patch(
"homeassistant.components.plugwise.coordinator.Smile", autospec=True
) as smile_mock:
smile = smile_mock.return_value
smile.gateway_id = "da224107914542988a88561b4452b0f6"
smile.heater_id = "056ee145a816487eaa69243c3280f8bf"
smile.smile_version = "3.6.4"
smile.smile_type = "thermostat"
smile.smile_hostname = "smile98765"
smile.smile_model = "Gateway"
smile.smile_model_id = "smile_open_therm"
smile.smile_name = "Adam"
smile.connect.return_value = Version("3.6.4")
all_data = _read_json(chosen_env, "all_data")
smile.async_update.return_value = PlugwiseData(
all_data["devices"], all_data["gateway"]
)
yield smile
@pytest.fixture
def mock_smile_adam_3() -> Generator[MagicMock]:
"""Create a 3rd Mock Adam environment for testing exceptions."""
chosen_env = "m_adam_cooling"
with patch(
"homeassistant.components.plugwise.coordinator.Smile", autospec=True
) as smile_mock:
smile = smile_mock.return_value
smile.gateway_id = "da224107914542988a88561b4452b0f6"
smile.heater_id = "056ee145a816487eaa69243c3280f8bf"
smile.smile_version = "3.6.4"
smile.smile_type = "thermostat"
smile.smile_hostname = "smile98765"
smile.smile_model = "Gateway"
smile.smile_model_id = "smile_open_therm"
smile.smile_name = "Adam"
smile.connect.return_value = Version("3.6.4")
all_data = _read_json(chosen_env, "all_data")
smile.async_update.return_value = PlugwiseData(
all_data["devices"], all_data["gateway"]
)
yield smile
@pytest.fixture
def mock_smile_adam_4() -> Generator[MagicMock]:
"""Create a 4th Mock Adam environment for testing exceptions."""
chosen_env = "m_adam_jip"
with patch(
"homeassistant.components.plugwise.coordinator.Smile", autospec=True
) as smile_mock:
smile = smile_mock.return_value
smile.gateway_id = "b5c2386c6f6342669e50fe49dd05b188"
smile.heater_id = "e4684553153b44afbef2200885f379dc"
smile.smile_version = "3.2.8"
smile.smile_type = "thermostat"
smile.smile_hostname = "smile98765"
smile.smile_model = "Gateway"
smile.smile_model_id = "smile_open_therm"
smile.smile_name = "Adam"
smile.connect.return_value = Version("3.2.8")
all_data = _read_json(chosen_env, "all_data")
smile.async_update.return_value = PlugwiseData(
all_data["devices"], all_data["gateway"]
)
yield smile
@pytest.fixture
def mock_smile_anna() -> Generator[MagicMock]:
"""Create a Mock Anna environment for testing exceptions."""
chosen_env = "anna_heatpump_heating"
with patch(
"homeassistant.components.plugwise.coordinator.Smile", autospec=True
) as smile_mock:
smile = smile_mock.return_value
smile.gateway_id = "015ae9ea3f964e668e490fa39da3870b"
smile.heater_id = "1cbf783bb11e4a7c8a6843dee3a86927"
smile.smile_version = "4.0.15"
smile.smile_type = "thermostat"
smile.smile_hostname = "smile98765"
smile.smile_model = "Gateway"
smile.smile_model_id = "smile_thermo"
smile.smile_name = "Smile Anna"
smile.connect.return_value = Version("4.0.15")
all_data = _read_json(chosen_env, "all_data")
smile.async_update.return_value = PlugwiseData(
all_data["devices"], all_data["gateway"]
)
yield smile
@pytest.fixture
def mock_smile_anna_2() -> Generator[MagicMock]:
"""Create a 2nd Mock Anna environment for testing exceptions."""
chosen_env = "m_anna_heatpump_cooling"
with patch(
"homeassistant.components.plugwise.coordinator.Smile", autospec=True
) as smile_mock:
smile = smile_mock.return_value
smile.gateway_id = "015ae9ea3f964e668e490fa39da3870b"
smile.heater_id = "1cbf783bb11e4a7c8a6843dee3a86927"
smile.smile_version = "4.0.15"
smile.smile_type = "thermostat"
smile.smile_hostname = "smile98765"
smile.smile_model = "Gateway"
smile.smile_model_id = "smile_thermo"
smile.smile_name = "Smile Anna"
smile.connect.return_value = Version("4.0.15")
all_data = _read_json(chosen_env, "all_data")
smile.async_update.return_value = PlugwiseData(
all_data["devices"], all_data["gateway"]
)
yield smile
@pytest.fixture
def mock_smile_anna_3() -> Generator[MagicMock]:
"""Create a 3rd Mock Anna environment for testing exceptions."""
chosen_env = "m_anna_heatpump_idle"
with patch(
"homeassistant.components.plugwise.coordinator.Smile", autospec=True
) as smile_mock:
smile = smile_mock.return_value
smile.gateway_id = "015ae9ea3f964e668e490fa39da3870b"
smile.heater_id = "1cbf783bb11e4a7c8a6843dee3a86927"
smile.smile_version = "4.0.15"
smile.smile_type = "thermostat"
smile.smile_hostname = "smile98765"
smile.smile_model = "Gateway"
smile.smile_model_id = "smile_thermo"
smile.smile_name = "Smile Anna"
smile.connect.return_value = Version("4.0.15")
all_data = _read_json(chosen_env, "all_data")
smile.async_update.return_value = PlugwiseData(
all_data["devices"], all_data["gateway"]
)
yield smile
@pytest.fixture
def mock_smile_p1() -> Generator[MagicMock]:
"""Create a Mock P1 DSMR environment for testing exceptions."""
chosen_env = "p1v4_442_single"
with patch(
"homeassistant.components.plugwise.coordinator.Smile", autospec=True
) as smile_mock:
smile = smile_mock.return_value
smile.gateway_id = "a455b61e52394b2db5081ce025a430f3"
smile.heater_id = None
smile.smile_version = "4.4.2"
smile.smile_type = "power"
smile.smile_hostname = "smile98765"
smile.smile_model = "Gateway"
smile.smile_model_id = "smile"
smile.smile_name = "Smile P1"
smile.connect.return_value = Version("4.4.2")
all_data = _read_json(chosen_env, "all_data")
smile.async_update.return_value = PlugwiseData(
all_data["devices"], all_data["gateway"]
)
yield smile
@pytest.fixture
def mock_smile_p1_2() -> Generator[MagicMock]:
"""Create a Mock P1 3-phase DSMR environment for testing exceptions."""
chosen_env = "p1v4_442_triple"
with patch(
"homeassistant.components.plugwise.coordinator.Smile", autospec=True
) as smile_mock:
smile = smile_mock.return_value
smile.gateway_id = "03e65b16e4b247a29ae0d75a78cb492e"
smile.heater_id = None
smile.smile_version = "4.4.2"
smile.smile_type = "power"
smile.smile_hostname = "smile98765"
smile.smile_model = "Gateway"
smile.smile_model_id = "smile"
smile.smile_name = "Smile P1"
smile.connect.return_value = Version("4.4.2")
all_data = _read_json(chosen_env, "all_data")
smile.async_update.return_value = PlugwiseData(
all_data["devices"], all_data["gateway"]
)
yield smile
@pytest.fixture
def mock_smile_legacy_anna() -> Generator[MagicMock]:
"""Create a Mock legacy Anna environment for testing exceptions."""
chosen_env = "legacy_anna"
with patch(
"homeassistant.components.plugwise.coordinator.Smile", autospec=True
) as smile_mock:
smile = smile_mock.return_value
smile.gateway_id = "0000aaaa0000aaaa0000aaaa0000aa00"
smile.heater_id = "04e4cbfe7f4340f090f85ec3b9e6a950"
smile.smile_version = "1.8.22"
smile.smile_type = "thermostat"
smile.smile_hostname = "smile98765"
smile.smile_model = "Gateway"
smile.smile_model_id = None
smile.smile_name = "Smile Anna"
smile.connect.return_value = Version("1.8.22")
all_data = _read_json(chosen_env, "all_data")
smile.async_update.return_value = PlugwiseData(
all_data["devices"], all_data["gateway"]
)
yield smile
@pytest.fixture
def mock_stretch() -> Generator[MagicMock]:
"""Create a Mock Stretch environment for testing exceptions."""
chosen_env = "stretch_v31"
with patch(
"homeassistant.components.plugwise.coordinator.Smile", autospec=True
) as smile_mock:
smile = smile_mock.return_value
smile.gateway_id = "259882df3c05415b99c2d962534ce820"
smile.heater_id = None
smile.smile_version = "3.1.11"
smile.smile_type = "stretch"
smile.smile_hostname = "stretch98765"
smile.smile_model = "Gateway"
smile.smile_model_id = None
smile.smile_name = "Stretch"
smile.connect.return_value = Version("3.1.11")
all_data = _read_json(chosen_env, "all_data")
smile.async_update.return_value = PlugwiseData(
all_data["devices"], all_data["gateway"]
)
yield smile
@pytest.fixture
async def init_integration(
hass: HomeAssistant, mock_config_entry: MockConfigEntry
) -> MockConfigEntry:
"""Set up the Plugwise integration for testing."""
mock_config_entry.add_to_hass(hass)
await hass.config_entries.async_setup(mock_config_entry.entry_id)
await hass.async_block_till_done()
return mock_config_entry

View File

@@ -0,0 +1,107 @@
{
"devices": {
"015ae9ea3f964e668e490fa39da3870b": {
"binary_sensors": {
"plugwise_notification": false
},
"dev_class": "gateway",
"firmware": "4.0.15",
"hardware": "AME Smile 2.0 board",
"location": "a57efe5f145f498c9be62a9b63626fbf",
"mac_address": "012345670001",
"model": "Gateway",
"model_id": "smile_thermo",
"name": "Smile Anna",
"sensors": {
"outdoor_temperature": 20.2
},
"vendor": "Plugwise"
},
"1cbf783bb11e4a7c8a6843dee3a86927": {
"available": true,
"binary_sensors": {
"compressor_state": true,
"cooling_enabled": false,
"cooling_state": false,
"dhw_state": false,
"flame_state": false,
"heating_state": true,
"secondary_boiler_state": false
},
"dev_class": "heater_central",
"location": "a57efe5f145f498c9be62a9b63626fbf",
"max_dhw_temperature": {
"lower_bound": 35.0,
"resolution": 0.01,
"setpoint": 53.0,
"upper_bound": 60.0
},
"maximum_boiler_temperature": {
"lower_bound": 0.0,
"resolution": 1.0,
"setpoint": 60.0,
"upper_bound": 100.0
},
"model": "Generic heater/cooler",
"name": "OpenTherm",
"sensors": {
"dhw_temperature": 46.3,
"intended_boiler_temperature": 35.0,
"modulation_level": 52,
"outdoor_air_temperature": 3.0,
"return_temperature": 25.1,
"water_pressure": 1.57,
"water_temperature": 29.1
},
"switches": {
"dhw_cm_switch": false
},
"vendor": "Techneco"
},
"3cb70739631c4d17a86b8b12e8a5161b": {
"active_preset": "home",
"available_schedules": ["standaard", "off"],
"climate_mode": "auto",
"control_state": "heating",
"dev_class": "thermostat",
"firmware": "2018-02-08T11:15:53+01:00",
"hardware": "6539-1301-5002",
"location": "c784ee9fdab44e1395b8dee7d7a497d5",
"model": "ThermoTouch",
"name": "Anna",
"preset_modes": ["no_frost", "home", "away", "asleep", "vacation"],
"select_schedule": "standaard",
"sensors": {
"cooling_activation_outdoor_temperature": 21.0,
"cooling_deactivation_threshold": 4.0,
"illuminance": 86.0,
"setpoint_high": 30.0,
"setpoint_low": 20.5,
"temperature": 19.3
},
"temperature_offset": {
"lower_bound": -2.0,
"resolution": 0.1,
"setpoint": -0.5,
"upper_bound": 2.0
},
"thermostat": {
"lower_bound": 4.0,
"resolution": 0.1,
"setpoint_high": 30.0,
"setpoint_low": 20.5,
"upper_bound": 30.0
},
"vendor": "Plugwise"
}
},
"gateway": {
"cooling_present": true,
"gateway_id": "015ae9ea3f964e668e490fa39da3870b",
"heater_id": "1cbf783bb11e4a7c8a6843dee3a86927",
"item_count": 67,
"notifications": {},
"reboot": true,
"smile_name": "Smile Anna"
}
}

View File

@@ -0,0 +1,69 @@
{
"devices": {
"0000aaaa0000aaaa0000aaaa0000aa00": {
"dev_class": "gateway",
"firmware": "1.8.22",
"location": "0000aaaa0000aaaa0000aaaa0000aa00",
"mac_address": "01:23:45:67:89:AB",
"model": "Gateway",
"name": "Smile Anna",
"vendor": "Plugwise"
},
"04e4cbfe7f4340f090f85ec3b9e6a950": {
"binary_sensors": {
"flame_state": true,
"heating_state": true
},
"dev_class": "heater_central",
"location": "0000aaaa0000aaaa0000aaaa0000aa00",
"maximum_boiler_temperature": {
"lower_bound": 50.0,
"resolution": 1.0,
"setpoint": 50.0,
"upper_bound": 90.0
},
"model": "Generic heater",
"name": "OpenTherm",
"sensors": {
"dhw_temperature": 51.2,
"intended_boiler_temperature": 17.0,
"modulation_level": 0.0,
"return_temperature": 21.7,
"water_pressure": 1.2,
"water_temperature": 23.6
},
"vendor": "Bosch Thermotechniek B.V."
},
"0d266432d64443e283b5d708ae98b455": {
"active_preset": "home",
"climate_mode": "heat",
"control_state": "heating",
"dev_class": "thermostat",
"firmware": "2017-03-13T11:54:58+01:00",
"hardware": "6539-1301-500",
"location": "0000aaaa0000aaaa0000aaaa0000aa00",
"model": "ThermoTouch",
"name": "Anna",
"preset_modes": ["away", "vacation", "asleep", "home", "no_frost"],
"sensors": {
"illuminance": 150.8,
"setpoint": 20.5,
"temperature": 20.4
},
"thermostat": {
"lower_bound": 4.0,
"resolution": 0.1,
"setpoint": 20.5,
"upper_bound": 30.0
},
"vendor": "Plugwise"
}
},
"gateway": {
"cooling_present": false,
"gateway_id": "0000aaaa0000aaaa0000aaaa0000aa00",
"heater_id": "04e4cbfe7f4340f090f85ec3b9e6a950",
"item_count": 41,
"smile_name": "Smile Anna"
}
}

View File

@@ -0,0 +1,213 @@
{
"devices": {
"056ee145a816487eaa69243c3280f8bf": {
"available": true,
"binary_sensors": {
"cooling_state": true,
"dhw_state": false,
"flame_state": false,
"heating_state": false
},
"dev_class": "heater_central",
"location": "bc93488efab249e5bc54fd7e175a6f91",
"maximum_boiler_temperature": {
"lower_bound": 25.0,
"resolution": 0.01,
"setpoint": 50.0,
"upper_bound": 95.0
},
"model": "Generic heater",
"name": "OpenTherm",
"sensors": {
"intended_boiler_temperature": 17.5,
"water_temperature": 19.0
},
"switches": {
"dhw_cm_switch": false
}
},
"1772a4ea304041adb83f357b751341ff": {
"available": true,
"binary_sensors": {
"low_battery": false
},
"dev_class": "thermostatic_radiator_valve",
"firmware": "2020-11-04T01:00:00+01:00",
"hardware": "1",
"location": "f871b8c4d63549319221e294e4f88074",
"model": "Tom/Floor",
"model_id": "106-03",
"name": "Tom Badkamer",
"sensors": {
"battery": 99,
"setpoint": 18.0,
"temperature": 21.6,
"temperature_difference": -0.2,
"valve_position": 100
},
"temperature_offset": {
"lower_bound": -2.0,
"resolution": 0.1,
"setpoint": 0.1,
"upper_bound": 2.0
},
"vendor": "Plugwise",
"zigbee_mac_address": "000D6F000C8FF5EE"
},
"ad4838d7d35c4d6ea796ee12ae5aedf8": {
"available": true,
"dev_class": "thermostat",
"location": "f2bf9048bef64cc5b6d5110154e33c81",
"model": "ThermoTouch",
"model_id": "143.1",
"name": "Anna",
"sensors": {
"setpoint": 23.5,
"temperature": 25.8
},
"vendor": "Plugwise"
},
"da224107914542988a88561b4452b0f6": {
"binary_sensors": {
"plugwise_notification": false
},
"dev_class": "gateway",
"firmware": "3.7.8",
"gateway_modes": ["away", "full", "vacation"],
"hardware": "AME Smile 2.0 board",
"location": "bc93488efab249e5bc54fd7e175a6f91",
"mac_address": "012345679891",
"model": "Gateway",
"model_id": "smile_open_therm",
"name": "Adam",
"regulation_modes": [
"bleeding_hot",
"bleeding_cold",
"off",
"heating",
"cooling"
],
"select_gateway_mode": "full",
"select_regulation_mode": "cooling",
"sensors": {
"outdoor_temperature": 29.65
},
"vendor": "Plugwise",
"zigbee_mac_address": "000D6F000D5A168D"
},
"e2f4322d57924fa090fbbc48b3a140dc": {
"available": true,
"binary_sensors": {
"low_battery": true
},
"dev_class": "zone_thermostat",
"firmware": "2016-10-10T02:00:00+02:00",
"hardware": "255",
"location": "f871b8c4d63549319221e294e4f88074",
"model": "Lisa",
"model_id": "158-01",
"name": "Lisa Badkamer",
"sensors": {
"battery": 14,
"setpoint": 23.5,
"temperature": 23.9
},
"temperature_offset": {
"lower_bound": -2.0,
"resolution": 0.1,
"setpoint": 0.0,
"upper_bound": 2.0
},
"vendor": "Plugwise",
"zigbee_mac_address": "000D6F000C869B61"
},
"e8ef2a01ed3b4139a53bf749204fe6b4": {
"dev_class": "switching",
"members": [
"2568cc4b9c1e401495d4741a5f89bee1",
"29542b2b6a6a4169acecc15c72a599b8"
],
"model": "Switchgroup",
"name": "Test",
"switches": {
"relay": true
},
"vendor": "Plugwise"
},
"f2bf9048bef64cc5b6d5110154e33c81": {
"active_preset": "home",
"available_schedules": [
"Badkamer",
"Test",
"Vakantie",
"Weekschema",
"off"
],
"climate_mode": "cool",
"control_state": "cooling",
"dev_class": "climate",
"model": "ThermoZone",
"name": "Living room",
"preset_modes": ["no_frost", "asleep", "vacation", "home", "away"],
"select_schedule": "off",
"sensors": {
"electricity_consumed": 149.9,
"electricity_produced": 0.0,
"temperature": 25.8
},
"thermostat": {
"lower_bound": 1.0,
"resolution": 0.01,
"setpoint": 23.5,
"upper_bound": 35.0
},
"thermostats": {
"primary": ["ad4838d7d35c4d6ea796ee12ae5aedf8"],
"secondary": []
},
"vendor": "Plugwise"
},
"f871b8c4d63549319221e294e4f88074": {
"active_preset": "home",
"available_schedules": [
"Badkamer",
"Test",
"Vakantie",
"Weekschema",
"off"
],
"climate_mode": "auto",
"control_state": "cooling",
"dev_class": "climate",
"model": "ThermoZone",
"name": "Bathroom",
"preset_modes": ["no_frost", "asleep", "vacation", "home", "away"],
"select_schedule": "Badkamer",
"sensors": {
"electricity_consumed": 0.0,
"electricity_produced": 0.0,
"temperature": 23.9
},
"thermostat": {
"lower_bound": 0.0,
"resolution": 0.01,
"setpoint": 25.0,
"upper_bound": 99.9
},
"thermostats": {
"primary": ["e2f4322d57924fa090fbbc48b3a140dc"],
"secondary": ["1772a4ea304041adb83f357b751341ff"]
},
"vendor": "Plugwise"
}
},
"gateway": {
"cooling_present": true,
"gateway_id": "da224107914542988a88561b4452b0f6",
"heater_id": "056ee145a816487eaa69243c3280f8bf",
"item_count": 89,
"notifications": {},
"reboot": true,
"smile_name": "Adam"
}
}

View File

@@ -0,0 +1,212 @@
{
"devices": {
"056ee145a816487eaa69243c3280f8bf": {
"available": true,
"binary_sensors": {
"dhw_state": false,
"flame_state": false,
"heating_state": true
},
"dev_class": "heater_central",
"location": "bc93488efab249e5bc54fd7e175a6f91",
"max_dhw_temperature": {
"lower_bound": 40.0,
"resolution": 0.01,
"setpoint": 60.0,
"upper_bound": 60.0
},
"maximum_boiler_temperature": {
"lower_bound": 25.0,
"resolution": 0.01,
"setpoint": 50.0,
"upper_bound": 95.0
},
"model": "Generic heater",
"name": "OpenTherm",
"sensors": {
"intended_boiler_temperature": 38.1,
"water_temperature": 37.0
},
"switches": {
"dhw_cm_switch": false
}
},
"1772a4ea304041adb83f357b751341ff": {
"available": true,
"binary_sensors": {
"low_battery": false
},
"dev_class": "thermostatic_radiator_valve",
"firmware": "2020-11-04T01:00:00+01:00",
"hardware": "1",
"location": "f871b8c4d63549319221e294e4f88074",
"model": "Tom/Floor",
"model_id": "106-03",
"name": "Tom Badkamer",
"sensors": {
"battery": 99,
"setpoint": 18.0,
"temperature": 18.6,
"temperature_difference": -0.2,
"valve_position": 100
},
"temperature_offset": {
"lower_bound": -2.0,
"resolution": 0.1,
"setpoint": 0.1,
"upper_bound": 2.0
},
"vendor": "Plugwise",
"zigbee_mac_address": "000D6F000C8FF5EE"
},
"ad4838d7d35c4d6ea796ee12ae5aedf8": {
"available": true,
"dev_class": "thermostat",
"location": "f2bf9048bef64cc5b6d5110154e33c81",
"model": "ThermoTouch",
"model_id": "143.1",
"name": "Anna",
"sensors": {
"setpoint": 20.0,
"temperature": 19.1
},
"vendor": "Plugwise"
},
"da224107914542988a88561b4452b0f6": {
"binary_sensors": {
"plugwise_notification": false
},
"dev_class": "gateway",
"firmware": "3.7.8",
"gateway_modes": ["away", "full", "vacation"],
"hardware": "AME Smile 2.0 board",
"location": "bc93488efab249e5bc54fd7e175a6f91",
"mac_address": "012345679891",
"model": "Gateway",
"model_id": "smile_open_therm",
"name": "Adam",
"regulation_modes": ["bleeding_hot", "bleeding_cold", "off", "heating"],
"select_gateway_mode": "full",
"select_regulation_mode": "heating",
"sensors": {
"outdoor_temperature": -1.25
},
"vendor": "Plugwise",
"zigbee_mac_address": "000D6F000D5A168D"
},
"e2f4322d57924fa090fbbc48b3a140dc": {
"available": true,
"binary_sensors": {
"low_battery": true
},
"dev_class": "zone_thermostat",
"firmware": "2016-10-10T02:00:00+02:00",
"hardware": "255",
"location": "f871b8c4d63549319221e294e4f88074",
"model": "Lisa",
"model_id": "158-01",
"name": "Lisa Badkamer",
"sensors": {
"battery": 14,
"setpoint": 15.0,
"temperature": 17.9
},
"temperature_offset": {
"lower_bound": -2.0,
"resolution": 0.1,
"setpoint": 0.0,
"upper_bound": 2.0
},
"vendor": "Plugwise",
"zigbee_mac_address": "000D6F000C869B61"
},
"e8ef2a01ed3b4139a53bf749204fe6b4": {
"dev_class": "switching",
"members": [
"2568cc4b9c1e401495d4741a5f89bee1",
"29542b2b6a6a4169acecc15c72a599b8"
],
"model": "Switchgroup",
"name": "Test",
"switches": {
"relay": true
},
"vendor": "Plugwise"
},
"f2bf9048bef64cc5b6d5110154e33c81": {
"active_preset": "home",
"available_schedules": [
"Badkamer",
"Test",
"Vakantie",
"Weekschema",
"off"
],
"climate_mode": "heat",
"control_state": "preheating",
"dev_class": "climate",
"model": "ThermoZone",
"name": "Living room",
"preset_modes": ["no_frost", "asleep", "vacation", "home", "away"],
"select_schedule": "off",
"sensors": {
"electricity_consumed": 149.9,
"electricity_produced": 0.0,
"temperature": 19.1
},
"thermostat": {
"lower_bound": 1.0,
"resolution": 0.01,
"setpoint": 20.0,
"upper_bound": 35.0
},
"thermostats": {
"primary": ["ad4838d7d35c4d6ea796ee12ae5aedf8"],
"secondary": []
},
"vendor": "Plugwise"
},
"f871b8c4d63549319221e294e4f88074": {
"active_preset": "home",
"available_schedules": [
"Badkamer",
"Test",
"Vakantie",
"Weekschema",
"off"
],
"climate_mode": "auto",
"control_state": "idle",
"dev_class": "climate",
"model": "ThermoZone",
"name": "Bathroom",
"preset_modes": ["no_frost", "asleep", "vacation", "home", "away"],
"select_schedule": "Badkamer",
"sensors": {
"electricity_consumed": 0.0,
"electricity_produced": 0.0,
"temperature": 17.9
},
"thermostat": {
"lower_bound": 0.0,
"resolution": 0.01,
"setpoint": 15.0,
"upper_bound": 99.9
},
"thermostats": {
"primary": ["e2f4322d57924fa090fbbc48b3a140dc"],
"secondary": ["1772a4ea304041adb83f357b751341ff"]
},
"vendor": "Plugwise"
}
},
"gateway": {
"cooling_present": false,
"gateway_id": "da224107914542988a88561b4452b0f6",
"heater_id": "056ee145a816487eaa69243c3280f8bf",
"item_count": 89,
"notifications": {},
"reboot": true,
"smile_name": "Adam"
}
}

View File

@@ -0,0 +1,380 @@
{
"devices": {
"06aecb3d00354375924f50c47af36bd2": {
"active_preset": "no_frost",
"climate_mode": "off",
"dev_class": "climate",
"model": "ThermoZone",
"name": "Slaapkamer",
"preset_modes": ["home", "asleep", "away", "vacation", "no_frost"],
"sensors": {
"temperature": 24.2
},
"thermostat": {
"lower_bound": 0.0,
"resolution": 0.01,
"setpoint": 13.0,
"upper_bound": 99.9
},
"thermostats": {
"primary": ["1346fbd8498d4dbcab7e18d51b771f3d"],
"secondary": ["356b65335e274d769c338223e7af9c33"]
},
"vendor": "Plugwise"
},
"13228dab8ce04617af318a2888b3c548": {
"active_preset": "home",
"climate_mode": "heat",
"control_state": "idle",
"dev_class": "climate",
"model": "ThermoZone",
"name": "Woonkamer",
"preset_modes": ["home", "asleep", "away", "vacation", "no_frost"],
"sensors": {
"temperature": 27.4
},
"thermostat": {
"lower_bound": 4.0,
"resolution": 0.01,
"setpoint": 9.0,
"upper_bound": 30.0
},
"thermostats": {
"primary": ["f61f1a2535f54f52ad006a3d18e459ca"],
"secondary": ["833de10f269c4deab58fb9df69901b4e"]
},
"vendor": "Plugwise"
},
"1346fbd8498d4dbcab7e18d51b771f3d": {
"available": true,
"binary_sensors": {
"low_battery": false
},
"dev_class": "zone_thermostat",
"firmware": "2016-10-27T02:00:00+02:00",
"hardware": "255",
"location": "06aecb3d00354375924f50c47af36bd2",
"model": "Lisa",
"model_id": "158-01",
"name": "Slaapkamer",
"sensors": {
"battery": 92,
"setpoint": 13.0,
"temperature": 24.2
},
"temperature_offset": {
"lower_bound": -2.0,
"resolution": 0.1,
"setpoint": 0.0,
"upper_bound": 2.0
},
"vendor": "Plugwise",
"zigbee_mac_address": "ABCD012345670A03"
},
"1da4d325838e4ad8aac12177214505c9": {
"available": true,
"dev_class": "thermostatic_radiator_valve",
"firmware": "2020-11-04T01:00:00+01:00",
"hardware": "1",
"location": "d58fec52899f4f1c92e4f8fad6d8c48c",
"model": "Tom/Floor",
"model_id": "106-03",
"name": "Tom Logeerkamer",
"sensors": {
"setpoint": 13.0,
"temperature": 28.8,
"temperature_difference": 2.0,
"valve_position": 0.0
},
"temperature_offset": {
"lower_bound": -2.0,
"resolution": 0.1,
"setpoint": 0.1,
"upper_bound": 2.0
},
"vendor": "Plugwise",
"zigbee_mac_address": "ABCD012345670A07"
},
"356b65335e274d769c338223e7af9c33": {
"available": true,
"dev_class": "thermostatic_radiator_valve",
"firmware": "2020-11-04T01:00:00+01:00",
"hardware": "1",
"location": "06aecb3d00354375924f50c47af36bd2",
"model": "Tom/Floor",
"model_id": "106-03",
"name": "Tom Slaapkamer",
"sensors": {
"setpoint": 13.0,
"temperature": 24.2,
"temperature_difference": 1.7,
"valve_position": 0.0
},
"temperature_offset": {
"lower_bound": -2.0,
"resolution": 0.1,
"setpoint": 0.1,
"upper_bound": 2.0
},
"vendor": "Plugwise",
"zigbee_mac_address": "ABCD012345670A05"
},
"457ce8414de24596a2d5e7dbc9c7682f": {
"available": true,
"dev_class": "zz_misc_plug",
"location": "9e4433a9d69f40b3aefd15e74395eaec",
"model": "Aqara Smart Plug",
"model_id": "lumi.plug.maeu01",
"name": "Plug",
"sensors": {
"electricity_consumed_interval": 0.0
},
"switches": {
"lock": true,
"relay": false
},
"vendor": "LUMI",
"zigbee_mac_address": "ABCD012345670A06"
},
"6f3e9d7084214c21b9dfa46f6eeb8700": {
"available": true,
"binary_sensors": {
"low_battery": false
},
"dev_class": "zone_thermostat",
"firmware": "2016-10-27T02:00:00+02:00",
"hardware": "255",
"location": "d27aede973b54be484f6842d1b2802ad",
"model": "Lisa",
"model_id": "158-01",
"name": "Kinderkamer",
"sensors": {
"battery": 79,
"setpoint": 13.0,
"temperature": 30.0
},
"temperature_offset": {
"lower_bound": -2.0,
"resolution": 0.1,
"setpoint": 0.0,
"upper_bound": 2.0
},
"vendor": "Plugwise",
"zigbee_mac_address": "ABCD012345670A02"
},
"833de10f269c4deab58fb9df69901b4e": {
"available": true,
"dev_class": "thermostatic_radiator_valve",
"firmware": "2020-11-04T01:00:00+01:00",
"hardware": "1",
"location": "13228dab8ce04617af318a2888b3c548",
"model": "Tom/Floor",
"model_id": "106-03",
"name": "Tom Woonkamer",
"sensors": {
"setpoint": 9.0,
"temperature": 24.0,
"temperature_difference": 1.8,
"valve_position": 100
},
"temperature_offset": {
"lower_bound": -2.0,
"resolution": 0.1,
"setpoint": 0.1,
"upper_bound": 2.0
},
"vendor": "Plugwise",
"zigbee_mac_address": "ABCD012345670A09"
},
"a6abc6a129ee499c88a4d420cc413b47": {
"available": true,
"binary_sensors": {
"low_battery": false
},
"dev_class": "zone_thermostat",
"firmware": "2016-10-27T02:00:00+02:00",
"hardware": "255",
"location": "d58fec52899f4f1c92e4f8fad6d8c48c",
"model": "Lisa",
"model_id": "158-01",
"name": "Logeerkamer",
"sensors": {
"battery": 80,
"setpoint": 13.0,
"temperature": 30.0
},
"temperature_offset": {
"lower_bound": -2.0,
"resolution": 0.1,
"setpoint": 0.0,
"upper_bound": 2.0
},
"vendor": "Plugwise",
"zigbee_mac_address": "ABCD012345670A01"
},
"b5c2386c6f6342669e50fe49dd05b188": {
"binary_sensors": {
"plugwise_notification": false
},
"dev_class": "gateway",
"firmware": "3.2.8",
"gateway_modes": ["away", "full", "vacation"],
"hardware": "AME Smile 2.0 board",
"location": "9e4433a9d69f40b3aefd15e74395eaec",
"mac_address": "012345670001",
"model": "Gateway",
"model_id": "smile_open_therm",
"name": "Adam",
"regulation_modes": ["heating", "off", "bleeding_cold", "bleeding_hot"],
"select_gateway_mode": "full",
"select_regulation_mode": "heating",
"sensors": {
"outdoor_temperature": 24.9
},
"vendor": "Plugwise",
"zigbee_mac_address": "ABCD012345670101"
},
"d27aede973b54be484f6842d1b2802ad": {
"active_preset": "home",
"climate_mode": "heat",
"control_state": "idle",
"dev_class": "climate",
"model": "ThermoZone",
"name": "Kinderkamer",
"preset_modes": ["home", "asleep", "away", "vacation", "no_frost"],
"sensors": {
"temperature": 30.0
},
"thermostat": {
"lower_bound": 0.0,
"resolution": 0.01,
"setpoint": 13.0,
"upper_bound": 99.9
},
"thermostats": {
"primary": ["6f3e9d7084214c21b9dfa46f6eeb8700"],
"secondary": ["d4496250d0e942cfa7aea3476e9070d5"]
},
"vendor": "Plugwise"
},
"d4496250d0e942cfa7aea3476e9070d5": {
"available": true,
"dev_class": "thermostatic_radiator_valve",
"firmware": "2020-11-04T01:00:00+01:00",
"hardware": "1",
"location": "d27aede973b54be484f6842d1b2802ad",
"model": "Tom/Floor",
"model_id": "106-03",
"name": "Tom Kinderkamer",
"sensors": {
"setpoint": 13.0,
"temperature": 28.7,
"temperature_difference": 1.9,
"valve_position": 0.0
},
"temperature_offset": {
"lower_bound": -2.0,
"resolution": 0.1,
"setpoint": 0.1,
"upper_bound": 2.0
},
"vendor": "Plugwise",
"zigbee_mac_address": "ABCD012345670A04"
},
"d58fec52899f4f1c92e4f8fad6d8c48c": {
"active_preset": "home",
"climate_mode": "heat",
"control_state": "idle",
"dev_class": "climate",
"model": "ThermoZone",
"name": "Logeerkamer",
"preset_modes": ["home", "asleep", "away", "vacation", "no_frost"],
"sensors": {
"temperature": 30.0
},
"thermostat": {
"lower_bound": 0.0,
"resolution": 0.01,
"setpoint": 13.0,
"upper_bound": 99.9
},
"thermostats": {
"primary": ["a6abc6a129ee499c88a4d420cc413b47"],
"secondary": ["1da4d325838e4ad8aac12177214505c9"]
},
"vendor": "Plugwise"
},
"e4684553153b44afbef2200885f379dc": {
"available": true,
"binary_sensors": {
"dhw_state": false,
"flame_state": false,
"heating_state": false
},
"dev_class": "heater_central",
"location": "9e4433a9d69f40b3aefd15e74395eaec",
"max_dhw_temperature": {
"lower_bound": 40.0,
"resolution": 0.01,
"setpoint": 60.0,
"upper_bound": 60.0
},
"maximum_boiler_temperature": {
"lower_bound": 20.0,
"resolution": 0.01,
"setpoint": 90.0,
"upper_bound": 90.0
},
"model": "Generic heater",
"model_id": "10.20",
"name": "OpenTherm",
"sensors": {
"intended_boiler_temperature": 0.0,
"modulation_level": 0.0,
"return_temperature": 37.1,
"water_pressure": 1.4,
"water_temperature": 37.3
},
"switches": {
"dhw_cm_switch": false
},
"vendor": "Remeha B.V."
},
"f61f1a2535f54f52ad006a3d18e459ca": {
"available": true,
"binary_sensors": {
"low_battery": false
},
"dev_class": "zone_thermometer",
"firmware": "2020-09-01T02:00:00+02:00",
"hardware": "1",
"location": "13228dab8ce04617af318a2888b3c548",
"model": "Jip",
"model_id": "168-01",
"name": "Woonkamer",
"sensors": {
"battery": 100,
"humidity": 56.2,
"setpoint": 9.0,
"temperature": 27.4
},
"temperature_offset": {
"lower_bound": -2.0,
"resolution": 0.1,
"setpoint": 0.0,
"upper_bound": 2.0
},
"vendor": "Plugwise",
"zigbee_mac_address": "ABCD012345670A08"
}
},
"gateway": {
"cooling_present": false,
"gateway_id": "b5c2386c6f6342669e50fe49dd05b188",
"heater_id": "e4684553153b44afbef2200885f379dc",
"item_count": 244,
"notifications": {},
"reboot": true,
"smile_name": "Adam"
}
}

View File

@@ -0,0 +1,594 @@
{
"devices": {
"02cf28bfec924855854c544690a609ef": {
"available": true,
"dev_class": "vcr_plug",
"firmware": "2019-06-21T02:00:00+02:00",
"location": "cd143c07248f491493cea0533bc3d669",
"model": "Plug",
"model_id": "160-01",
"name": "NVR",
"sensors": {
"electricity_consumed": 34.0,
"electricity_consumed_interval": 9.15,
"electricity_produced": 0.0,
"electricity_produced_interval": 0.0
},
"switches": {
"lock": true,
"relay": true
},
"vendor": "Plugwise",
"zigbee_mac_address": "ABCD012345670A15"
},
"08963fec7c53423ca5680aa4cb502c63": {
"active_preset": "away",
"available_schedules": [
"CV Roan",
"Bios Schema met Film Avond",
"GF7 Woonkamer",
"Badkamer Schema",
"CV Jessie",
"off"
],
"climate_mode": "auto",
"control_state": "idle",
"dev_class": "climate",
"model": "ThermoZone",
"name": "Badkamer",
"preset_modes": ["home", "asleep", "away", "vacation", "no_frost"],
"select_schedule": "Badkamer Schema",
"sensors": {
"temperature": 18.9
},
"thermostat": {
"lower_bound": 0.0,
"resolution": 0.01,
"setpoint": 14.0,
"upper_bound": 100.0
},
"thermostats": {
"primary": [
"f1fee6043d3642a9b0a65297455f008e",
"680423ff840043738f42cc7f1ff97a36"
],
"secondary": []
},
"vendor": "Plugwise"
},
"12493538af164a409c6a1c79e38afe1c": {
"active_preset": "away",
"available_schedules": [
"CV Roan",
"Bios Schema met Film Avond",
"GF7 Woonkamer",
"Badkamer Schema",
"CV Jessie",
"off"
],
"climate_mode": "heat",
"control_state": "idle",
"dev_class": "climate",
"model": "ThermoZone",
"name": "Bios",
"preset_modes": ["home", "asleep", "away", "vacation", "no_frost"],
"select_schedule": "off",
"sensors": {
"electricity_consumed": 0.0,
"electricity_produced": 0.0,
"temperature": 16.5
},
"thermostat": {
"lower_bound": 0.0,
"resolution": 0.01,
"setpoint": 13.0,
"upper_bound": 100.0
},
"thermostats": {
"primary": ["df4a4a8169904cdb9c03d61a21f42140"],
"secondary": ["a2c3583e0a6349358998b760cea82d2a"]
},
"vendor": "Plugwise"
},
"21f2b542c49845e6bb416884c55778d6": {
"available": true,
"dev_class": "game_console_plug",
"firmware": "2019-06-21T02:00:00+02:00",
"location": "cd143c07248f491493cea0533bc3d669",
"model": "Plug",
"model_id": "160-01",
"name": "Playstation Smart Plug",
"sensors": {
"electricity_consumed": 84.1,
"electricity_consumed_interval": 8.6,
"electricity_produced": 0.0,
"electricity_produced_interval": 0.0
},
"switches": {
"lock": false,
"relay": true
},
"vendor": "Plugwise",
"zigbee_mac_address": "ABCD012345670A12"
},
"446ac08dd04d4eff8ac57489757b7314": {
"active_preset": "no_frost",
"climate_mode": "heat",
"control_state": "idle",
"dev_class": "climate",
"model": "ThermoZone",
"name": "Garage",
"preset_modes": ["home", "asleep", "away", "vacation", "no_frost"],
"sensors": {
"temperature": 15.6
},
"thermostat": {
"lower_bound": 0.0,
"resolution": 0.01,
"setpoint": 5.5,
"upper_bound": 100.0
},
"thermostats": {
"primary": ["e7693eb9582644e5b865dba8d4447cf1"],
"secondary": []
},
"vendor": "Plugwise"
},
"4a810418d5394b3f82727340b91ba740": {
"available": true,
"dev_class": "router_plug",
"firmware": "2019-06-21T02:00:00+02:00",
"location": "cd143c07248f491493cea0533bc3d669",
"model": "Plug",
"model_id": "160-01",
"name": "USG Smart Plug",
"sensors": {
"electricity_consumed": 8.5,
"electricity_consumed_interval": 0.0,
"electricity_produced": 0.0,
"electricity_produced_interval": 0.0
},
"switches": {
"lock": true,
"relay": true
},
"vendor": "Plugwise",
"zigbee_mac_address": "ABCD012345670A16"
},
"675416a629f343c495449970e2ca37b5": {
"available": true,
"dev_class": "router_plug",
"firmware": "2019-06-21T02:00:00+02:00",
"location": "cd143c07248f491493cea0533bc3d669",
"model": "Plug",
"model_id": "160-01",
"name": "Ziggo Modem",
"sensors": {
"electricity_consumed": 12.2,
"electricity_consumed_interval": 2.97,
"electricity_produced": 0.0,
"electricity_produced_interval": 0.0
},
"switches": {
"lock": true,
"relay": true
},
"vendor": "Plugwise",
"zigbee_mac_address": "ABCD012345670A01"
},
"680423ff840043738f42cc7f1ff97a36": {
"available": true,
"binary_sensors": {
"low_battery": false
},
"dev_class": "thermostatic_radiator_valve",
"firmware": "2019-03-27T01:00:00+01:00",
"hardware": "1",
"location": "08963fec7c53423ca5680aa4cb502c63",
"model": "Tom/Floor",
"model_id": "106-03",
"name": "Thermostatic Radiator Badkamer 1",
"sensors": {
"battery": 51,
"setpoint": 14.0,
"temperature": 19.1,
"temperature_difference": -0.4,
"valve_position": 0.0
},
"temperature_offset": {
"lower_bound": -2.0,
"resolution": 0.1,
"setpoint": 0.0,
"upper_bound": 2.0
},
"vendor": "Plugwise",
"zigbee_mac_address": "ABCD012345670A17"
},
"6a3bf693d05e48e0b460c815a4fdd09d": {
"available": true,
"binary_sensors": {
"low_battery": false
},
"dev_class": "zone_thermostat",
"firmware": "2016-10-27T02:00:00+02:00",
"hardware": "255",
"location": "82fa13f017d240daa0d0ea1775420f24",
"model": "Lisa",
"model_id": "158-01",
"name": "Zone Thermostat Jessie",
"sensors": {
"battery": 37,
"setpoint": 15.0,
"temperature": 17.2
},
"temperature_offset": {
"lower_bound": -2.0,
"resolution": 0.1,
"setpoint": 0.0,
"upper_bound": 2.0
},
"vendor": "Plugwise",
"zigbee_mac_address": "ABCD012345670A03"
},
"78d1126fc4c743db81b61c20e88342a7": {
"available": true,
"dev_class": "central_heating_pump_plug",
"firmware": "2019-06-21T02:00:00+02:00",
"location": "c50f167537524366a5af7aa3942feb1e",
"model": "Plug",
"model_id": "160-01",
"name": "CV Pomp",
"sensors": {
"electricity_consumed": 35.6,
"electricity_consumed_interval": 7.37,
"electricity_produced": 0.0,
"electricity_produced_interval": 0.0
},
"switches": {
"relay": true
},
"vendor": "Plugwise",
"zigbee_mac_address": "ABCD012345670A05"
},
"82fa13f017d240daa0d0ea1775420f24": {
"active_preset": "asleep",
"available_schedules": [
"CV Roan",
"Bios Schema met Film Avond",
"GF7 Woonkamer",
"Badkamer Schema",
"CV Jessie",
"off"
],
"climate_mode": "auto",
"control_state": "idle",
"dev_class": "climate",
"model": "ThermoZone",
"name": "Jessie",
"preset_modes": ["home", "asleep", "away", "vacation", "no_frost"],
"select_schedule": "CV Jessie",
"sensors": {
"temperature": 17.2
},
"thermostat": {
"lower_bound": 0.0,
"resolution": 0.01,
"setpoint": 15.0,
"upper_bound": 100.0
},
"thermostats": {
"primary": ["6a3bf693d05e48e0b460c815a4fdd09d"],
"secondary": ["d3da73bde12a47d5a6b8f9dad971f2ec"]
},
"vendor": "Plugwise"
},
"90986d591dcd426cae3ec3e8111ff730": {
"binary_sensors": {
"heating_state": true
},
"dev_class": "heater_central",
"location": "1f9dcf83fd4e4b66b72ff787957bfe5d",
"model": "Unknown",
"name": "OnOff",
"sensors": {
"intended_boiler_temperature": 70.0,
"modulation_level": 1,
"water_temperature": 70.0
}
},
"a28f588dc4a049a483fd03a30361ad3a": {
"available": true,
"dev_class": "settop_plug",
"firmware": "2019-06-21T02:00:00+02:00",
"location": "cd143c07248f491493cea0533bc3d669",
"model": "Plug",
"model_id": "160-01",
"name": "Fibaro HC2",
"sensors": {
"electricity_consumed": 12.5,
"electricity_consumed_interval": 3.8,
"electricity_produced": 0.0,
"electricity_produced_interval": 0.0
},
"switches": {
"lock": true,
"relay": true
},
"vendor": "Plugwise",
"zigbee_mac_address": "ABCD012345670A13"
},
"a2c3583e0a6349358998b760cea82d2a": {
"available": true,
"binary_sensors": {
"low_battery": false
},
"dev_class": "thermostatic_radiator_valve",
"firmware": "2019-03-27T01:00:00+01:00",
"hardware": "1",
"location": "12493538af164a409c6a1c79e38afe1c",
"model": "Tom/Floor",
"model_id": "106-03",
"name": "Bios Cv Thermostatic Radiator ",
"sensors": {
"battery": 62,
"setpoint": 13.0,
"temperature": 17.2,
"temperature_difference": -0.2,
"valve_position": 0.0
},
"temperature_offset": {
"lower_bound": -2.0,
"resolution": 0.1,
"setpoint": 0.0,
"upper_bound": 2.0
},
"vendor": "Plugwise",
"zigbee_mac_address": "ABCD012345670A09"
},
"b310b72a0e354bfab43089919b9a88bf": {
"available": true,
"dev_class": "thermostatic_radiator_valve",
"firmware": "2019-03-27T01:00:00+01:00",
"hardware": "1",
"location": "c50f167537524366a5af7aa3942feb1e",
"model": "Tom/Floor",
"model_id": "106-03",
"name": "Floor kraan",
"sensors": {
"setpoint": 21.5,
"temperature": 26.0,
"temperature_difference": 3.5,
"valve_position": 100
},
"temperature_offset": {
"lower_bound": -2.0,
"resolution": 0.1,
"setpoint": 0.0,
"upper_bound": 2.0
},
"vendor": "Plugwise",
"zigbee_mac_address": "ABCD012345670A02"
},
"b59bcebaf94b499ea7d46e4a66fb62d8": {
"available": true,
"binary_sensors": {
"low_battery": false
},
"dev_class": "zone_thermostat",
"firmware": "2016-08-02T02:00:00+02:00",
"hardware": "255",
"location": "c50f167537524366a5af7aa3942feb1e",
"model": "Lisa",
"model_id": "158-01",
"name": "Zone Lisa WK",
"sensors": {
"battery": 34,
"setpoint": 21.5,
"temperature": 20.9
},
"temperature_offset": {
"lower_bound": -2.0,
"resolution": 0.1,
"setpoint": 0.0,
"upper_bound": 2.0
},
"vendor": "Plugwise",
"zigbee_mac_address": "ABCD012345670A07"
},
"c50f167537524366a5af7aa3942feb1e": {
"active_preset": "home",
"available_schedules": [
"CV Roan",
"Bios Schema met Film Avond",
"GF7 Woonkamer",
"Badkamer Schema",
"CV Jessie",
"off"
],
"climate_mode": "auto",
"control_state": "heating",
"dev_class": "climate",
"model": "ThermoZone",
"name": "Woonkamer",
"preset_modes": ["home", "asleep", "away", "vacation", "no_frost"],
"select_schedule": "GF7 Woonkamer",
"sensors": {
"electricity_consumed": 35.6,
"electricity_produced": 0.0,
"temperature": 20.9
},
"thermostat": {
"lower_bound": 0.0,
"resolution": 0.01,
"setpoint": 21.5,
"upper_bound": 100.0
},
"thermostats": {
"primary": ["b59bcebaf94b499ea7d46e4a66fb62d8"],
"secondary": ["b310b72a0e354bfab43089919b9a88bf"]
},
"vendor": "Plugwise"
},
"cd0ddb54ef694e11ac18ed1cbce5dbbd": {
"available": true,
"dev_class": "vcr_plug",
"firmware": "2019-06-21T02:00:00+02:00",
"location": "cd143c07248f491493cea0533bc3d669",
"model": "Plug",
"model_id": "160-01",
"name": "NAS",
"sensors": {
"electricity_consumed": 16.5,
"electricity_consumed_interval": 0.5,
"electricity_produced": 0.0,
"electricity_produced_interval": 0.0
},
"switches": {
"lock": true,
"relay": true
},
"vendor": "Plugwise",
"zigbee_mac_address": "ABCD012345670A14"
},
"d3da73bde12a47d5a6b8f9dad971f2ec": {
"available": true,
"binary_sensors": {
"low_battery": false
},
"dev_class": "thermostatic_radiator_valve",
"firmware": "2019-03-27T01:00:00+01:00",
"hardware": "1",
"location": "82fa13f017d240daa0d0ea1775420f24",
"model": "Tom/Floor",
"model_id": "106-03",
"name": "Thermostatic Radiator Jessie",
"sensors": {
"battery": 62,
"setpoint": 15.0,
"temperature": 17.1,
"temperature_difference": 0.1,
"valve_position": 0.0
},
"temperature_offset": {
"lower_bound": -2.0,
"resolution": 0.1,
"setpoint": 0.0,
"upper_bound": 2.0
},
"vendor": "Plugwise",
"zigbee_mac_address": "ABCD012345670A10"
},
"df4a4a8169904cdb9c03d61a21f42140": {
"available": true,
"binary_sensors": {
"low_battery": false
},
"dev_class": "zone_thermostat",
"firmware": "2016-10-27T02:00:00+02:00",
"hardware": "255",
"location": "12493538af164a409c6a1c79e38afe1c",
"model": "Lisa",
"model_id": "158-01",
"name": "Zone Lisa Bios",
"sensors": {
"battery": 67,
"setpoint": 13.0,
"temperature": 16.5
},
"temperature_offset": {
"lower_bound": -2.0,
"resolution": 0.1,
"setpoint": 0.0,
"upper_bound": 2.0
},
"vendor": "Plugwise",
"zigbee_mac_address": "ABCD012345670A06"
},
"e7693eb9582644e5b865dba8d4447cf1": {
"available": true,
"binary_sensors": {
"low_battery": false
},
"dev_class": "thermostatic_radiator_valve",
"firmware": "2019-03-27T01:00:00+01:00",
"hardware": "1",
"location": "446ac08dd04d4eff8ac57489757b7314",
"model": "Tom/Floor",
"model_id": "106-03",
"name": "CV Kraan Garage",
"sensors": {
"battery": 68,
"setpoint": 5.5,
"temperature": 15.6,
"temperature_difference": 0.0,
"valve_position": 0.0
},
"temperature_offset": {
"lower_bound": -2.0,
"resolution": 0.1,
"setpoint": 0.0,
"upper_bound": 2.0
},
"vendor": "Plugwise",
"zigbee_mac_address": "ABCD012345670A11"
},
"f1fee6043d3642a9b0a65297455f008e": {
"available": true,
"binary_sensors": {
"low_battery": false
},
"dev_class": "thermostatic_radiator_valve",
"firmware": "2016-10-27T02:00:00+02:00",
"hardware": "255",
"location": "08963fec7c53423ca5680aa4cb502c63",
"model": "Lisa",
"model_id": "158-01",
"name": "Thermostatic Radiator Badkamer 2",
"sensors": {
"battery": 92,
"setpoint": 14.0,
"temperature": 18.9
},
"temperature_offset": {
"lower_bound": -2.0,
"resolution": 0.1,
"setpoint": 0.0,
"upper_bound": 2.0
},
"vendor": "Plugwise",
"zigbee_mac_address": "ABCD012345670A08"
},
"fe799307f1624099878210aa0b9f1475": {
"binary_sensors": {
"plugwise_notification": true
},
"dev_class": "gateway",
"firmware": "3.0.15",
"hardware": "AME Smile 2.0 board",
"location": "1f9dcf83fd4e4b66b72ff787957bfe5d",
"mac_address": "012345670001",
"model": "Gateway",
"model_id": "smile_open_therm",
"name": "Adam",
"select_regulation_mode": "heating",
"sensors": {
"outdoor_temperature": 7.81
},
"vendor": "Plugwise",
"zigbee_mac_address": "ABCD012345670101"
}
},
"gateway": {
"cooling_present": false,
"gateway_id": "fe799307f1624099878210aa0b9f1475",
"heater_id": "90986d591dcd426cae3ec3e8111ff730",
"item_count": 369,
"notifications": {
"af82e4ccf9c548528166d38e560662a4": {
"warning": "Node Plug (with MAC address 000D6F000D13CB01, in room 'n.a.') has been unreachable since 23:03 2020-01-18. Please check the connection and restart the device."
}
},
"reboot": true,
"smile_name": "Adam"
}
}

View File

@@ -0,0 +1,107 @@
{
"devices": {
"015ae9ea3f964e668e490fa39da3870b": {
"binary_sensors": {
"plugwise_notification": false
},
"dev_class": "gateway",
"firmware": "4.0.15",
"hardware": "AME Smile 2.0 board",
"location": "a57efe5f145f498c9be62a9b63626fbf",
"mac_address": "012345670001",
"model": "Gateway",
"model_id": "smile_thermo",
"name": "Smile Anna",
"sensors": {
"outdoor_temperature": 28.2
},
"vendor": "Plugwise"
},
"1cbf783bb11e4a7c8a6843dee3a86927": {
"available": true,
"binary_sensors": {
"compressor_state": true,
"cooling_enabled": true,
"cooling_state": true,
"dhw_state": false,
"flame_state": false,
"heating_state": false,
"secondary_boiler_state": false
},
"dev_class": "heater_central",
"location": "a57efe5f145f498c9be62a9b63626fbf",
"max_dhw_temperature": {
"lower_bound": 35.0,
"resolution": 0.01,
"setpoint": 53.0,
"upper_bound": 60.0
},
"maximum_boiler_temperature": {
"lower_bound": 0.0,
"resolution": 1.0,
"setpoint": 60.0,
"upper_bound": 100.0
},
"model": "Generic heater/cooler",
"name": "OpenTherm",
"sensors": {
"dhw_temperature": 41.5,
"intended_boiler_temperature": 0.0,
"modulation_level": 40,
"outdoor_air_temperature": 28.0,
"return_temperature": 23.8,
"water_pressure": 1.57,
"water_temperature": 22.7
},
"switches": {
"dhw_cm_switch": false
},
"vendor": "Techneco"
},
"3cb70739631c4d17a86b8b12e8a5161b": {
"active_preset": "home",
"available_schedules": ["standaard", "off"],
"climate_mode": "auto",
"control_state": "cooling",
"dev_class": "thermostat",
"firmware": "2018-02-08T11:15:53+01:00",
"hardware": "6539-1301-5002",
"location": "c784ee9fdab44e1395b8dee7d7a497d5",
"model": "ThermoTouch",
"name": "Anna",
"preset_modes": ["no_frost", "home", "away", "asleep", "vacation"],
"select_schedule": "standaard",
"sensors": {
"cooling_activation_outdoor_temperature": 21.0,
"cooling_deactivation_threshold": 4.0,
"illuminance": 86.0,
"setpoint_high": 30.0,
"setpoint_low": 20.5,
"temperature": 26.3
},
"temperature_offset": {
"lower_bound": -2.0,
"resolution": 0.1,
"setpoint": -0.5,
"upper_bound": 2.0
},
"thermostat": {
"lower_bound": 4.0,
"resolution": 0.1,
"setpoint_high": 30.0,
"setpoint_low": 20.5,
"upper_bound": 30.0
},
"vendor": "Plugwise"
}
},
"gateway": {
"cooling_present": true,
"gateway_id": "015ae9ea3f964e668e490fa39da3870b",
"heater_id": "1cbf783bb11e4a7c8a6843dee3a86927",
"item_count": 67,
"notifications": {},
"reboot": true,
"smile_name": "Smile Anna"
}
}

View File

@@ -0,0 +1,107 @@
{
"devices": {
"015ae9ea3f964e668e490fa39da3870b": {
"binary_sensors": {
"plugwise_notification": false
},
"dev_class": "gateway",
"firmware": "4.0.15",
"hardware": "AME Smile 2.0 board",
"location": "a57efe5f145f498c9be62a9b63626fbf",
"mac_address": "012345670001",
"model": "Gateway",
"model_id": "smile_thermo",
"name": "Smile Anna",
"sensors": {
"outdoor_temperature": 28.2
},
"vendor": "Plugwise"
},
"1cbf783bb11e4a7c8a6843dee3a86927": {
"available": true,
"binary_sensors": {
"compressor_state": false,
"cooling_enabled": true,
"cooling_state": false,
"dhw_state": false,
"flame_state": false,
"heating_state": false,
"secondary_boiler_state": false
},
"dev_class": "heater_central",
"location": "a57efe5f145f498c9be62a9b63626fbf",
"max_dhw_temperature": {
"lower_bound": 35.0,
"resolution": 0.01,
"setpoint": 53.0,
"upper_bound": 60.0
},
"maximum_boiler_temperature": {
"lower_bound": 0.0,
"resolution": 1.0,
"setpoint": 60.0,
"upper_bound": 100.0
},
"model": "Generic heater/cooler",
"name": "OpenTherm",
"sensors": {
"dhw_temperature": 46.3,
"intended_boiler_temperature": 18.0,
"modulation_level": 0,
"outdoor_air_temperature": 28.2,
"return_temperature": 22.0,
"water_pressure": 1.57,
"water_temperature": 19.1
},
"switches": {
"dhw_cm_switch": false
},
"vendor": "Techneco"
},
"3cb70739631c4d17a86b8b12e8a5161b": {
"active_preset": "home",
"available_schedules": ["standaard", "off"],
"climate_mode": "auto",
"control_state": "idle",
"dev_class": "thermostat",
"firmware": "2018-02-08T11:15:53+01:00",
"hardware": "6539-1301-5002",
"location": "c784ee9fdab44e1395b8dee7d7a497d5",
"model": "ThermoTouch",
"name": "Anna",
"preset_modes": ["no_frost", "home", "away", "asleep", "vacation"],
"select_schedule": "standaard",
"sensors": {
"cooling_activation_outdoor_temperature": 25.0,
"cooling_deactivation_threshold": 4.0,
"illuminance": 86.0,
"setpoint_high": 30.0,
"setpoint_low": 20.5,
"temperature": 23.0
},
"temperature_offset": {
"lower_bound": -2.0,
"resolution": 0.1,
"setpoint": -0.5,
"upper_bound": 2.0
},
"thermostat": {
"lower_bound": 4.0,
"resolution": 0.1,
"setpoint_high": 30.0,
"setpoint_low": 20.5,
"upper_bound": 30.0
},
"vendor": "Plugwise"
}
},
"gateway": {
"cooling_present": true,
"gateway_id": "015ae9ea3f964e668e490fa39da3870b",
"heater_id": "1cbf783bb11e4a7c8a6843dee3a86927",
"item_count": 67,
"notifications": {},
"reboot": true,
"smile_name": "Smile Anna"
}
}

View File

@@ -0,0 +1,51 @@
{
"devices": {
"a455b61e52394b2db5081ce025a430f3": {
"binary_sensors": {
"plugwise_notification": false
},
"dev_class": "gateway",
"firmware": "4.4.2",
"hardware": "AME Smile 2.0 board",
"location": "a455b61e52394b2db5081ce025a430f3",
"mac_address": "012345670001",
"model": "Gateway",
"model_id": "smile",
"name": "Smile P1",
"vendor": "Plugwise"
},
"ba4de7613517478da82dd9b6abea36af": {
"available": true,
"dev_class": "smartmeter",
"location": "a455b61e52394b2db5081ce025a430f3",
"model": "KFM5KAIFA-METER",
"name": "P1",
"sensors": {
"electricity_consumed_off_peak_cumulative": 17643.423,
"electricity_consumed_off_peak_interval": 15,
"electricity_consumed_off_peak_point": 486,
"electricity_consumed_peak_cumulative": 13966.608,
"electricity_consumed_peak_interval": 0,
"electricity_consumed_peak_point": 0,
"electricity_phase_one_consumed": 486,
"electricity_phase_one_produced": 0,
"electricity_produced_off_peak_cumulative": 0.0,
"electricity_produced_off_peak_interval": 0,
"electricity_produced_off_peak_point": 0,
"electricity_produced_peak_cumulative": 0.0,
"electricity_produced_peak_interval": 0,
"electricity_produced_peak_point": 0,
"net_electricity_cumulative": 31610.031,
"net_electricity_point": 486
},
"vendor": "SHENZHEN KAIFA TECHNOLOGY \uff08CHENGDU\uff09 CO., LTD."
}
},
"gateway": {
"gateway_id": "a455b61e52394b2db5081ce025a430f3",
"item_count": 32,
"notifications": {},
"reboot": true,
"smile_name": "Smile P1"
}
}

View File

@@ -0,0 +1,64 @@
{
"devices": {
"03e65b16e4b247a29ae0d75a78cb492e": {
"binary_sensors": {
"plugwise_notification": true
},
"dev_class": "gateway",
"firmware": "4.4.2",
"hardware": "AME Smile 2.0 board",
"location": "03e65b16e4b247a29ae0d75a78cb492e",
"mac_address": "012345670001",
"model": "Gateway",
"model_id": "smile",
"name": "Smile P1",
"vendor": "Plugwise"
},
"b82b6b3322484f2ea4e25e0bd5f3d61f": {
"available": true,
"dev_class": "smartmeter",
"location": "03e65b16e4b247a29ae0d75a78cb492e",
"model": "XMX5LGF0010453051839",
"name": "P1",
"sensors": {
"electricity_consumed_off_peak_cumulative": 70537.898,
"electricity_consumed_off_peak_interval": 314,
"electricity_consumed_off_peak_point": 5553,
"electricity_consumed_peak_cumulative": 161328.641,
"electricity_consumed_peak_interval": 0,
"electricity_consumed_peak_point": 0,
"electricity_phase_one_consumed": 1763,
"electricity_phase_one_produced": 0,
"electricity_phase_three_consumed": 2080,
"electricity_phase_three_produced": 0,
"electricity_phase_two_consumed": 1703,
"electricity_phase_two_produced": 0,
"electricity_produced_off_peak_cumulative": 0.0,
"electricity_produced_off_peak_interval": 0,
"electricity_produced_off_peak_point": 0,
"electricity_produced_peak_cumulative": 0.0,
"electricity_produced_peak_interval": 0,
"electricity_produced_peak_point": 0,
"gas_consumed_cumulative": 16811.37,
"gas_consumed_interval": 0.06,
"net_electricity_cumulative": 231866.539,
"net_electricity_point": 5553,
"voltage_phase_one": 233.2,
"voltage_phase_three": 234.7,
"voltage_phase_two": 234.4
},
"vendor": "XEMEX NV"
}
},
"gateway": {
"gateway_id": "03e65b16e4b247a29ae0d75a78cb492e",
"item_count": 41,
"notifications": {
"97a04c0c263049b29350a660b4cdd01e": {
"warning": "The Smile P1 is not connected to a smart meter."
}
},
"reboot": true,
"smile_name": "Smile P1"
}
}

View File

@@ -0,0 +1,143 @@
{
"devices": {
"0000aaaa0000aaaa0000aaaa0000aa00": {
"dev_class": "gateway",
"firmware": "3.1.11",
"location": "0000aaaa0000aaaa0000aaaa0000aa00",
"mac_address": "01:23:45:67:89:AB",
"model": "Gateway",
"name": "Stretch",
"vendor": "Plugwise",
"zigbee_mac_address": "ABCD012345670101"
},
"059e4d03c7a34d278add5c7a4a781d19": {
"dev_class": "washingmachine",
"firmware": "2011-06-27T10:52:18+02:00",
"hardware": "0000-0440-0107",
"location": "0000aaaa0000aaaa0000aaaa0000aa00",
"model": "Circle type F",
"name": "Wasmachine (52AC1)",
"sensors": {
"electricity_consumed": 0.0,
"electricity_consumed_interval": 0.0,
"electricity_produced": 0.0
},
"switches": {
"lock": true,
"relay": true
},
"vendor": "Plugwise",
"zigbee_mac_address": "ABCD012345670A01"
},
"5871317346d045bc9f6b987ef25ee638": {
"dev_class": "water_heater_vessel",
"firmware": "2011-06-27T10:52:18+02:00",
"hardware": "6539-0701-4028",
"location": "0000aaaa0000aaaa0000aaaa0000aa00",
"model": "Circle type F",
"name": "Boiler (1EB31)",
"sensors": {
"electricity_consumed": 1.19,
"electricity_consumed_interval": 0.0,
"electricity_produced": 0.0
},
"switches": {
"lock": false,
"relay": true
},
"vendor": "Plugwise",
"zigbee_mac_address": "ABCD012345670A07"
},
"aac7b735042c4832ac9ff33aae4f453b": {
"dev_class": "dishwasher",
"firmware": "2011-06-27T10:52:18+02:00",
"hardware": "6539-0701-4022",
"location": "0000aaaa0000aaaa0000aaaa0000aa00",
"model": "Circle type F",
"name": "Vaatwasser (2a1ab)",
"sensors": {
"electricity_consumed": 0.0,
"electricity_consumed_interval": 0.71,
"electricity_produced": 0.0
},
"switches": {
"lock": false,
"relay": true
},
"vendor": "Plugwise",
"zigbee_mac_address": "ABCD012345670A02"
},
"cfe95cf3de1948c0b8955125bf754614": {
"dev_class": "dryer",
"firmware": "2011-06-27T10:52:18+02:00",
"hardware": "0000-0440-0107",
"location": "0000aaaa0000aaaa0000aaaa0000aa00",
"model": "Circle type F",
"name": "Droger (52559)",
"sensors": {
"electricity_consumed": 0.0,
"electricity_consumed_interval": 0.0,
"electricity_produced": 0.0
},
"switches": {
"lock": false,
"relay": true
},
"vendor": "Plugwise",
"zigbee_mac_address": "ABCD012345670A04"
},
"d03738edfcc947f7b8f4573571d90d2d": {
"dev_class": "switching",
"members": [
"059e4d03c7a34d278add5c7a4a781d19",
"cfe95cf3de1948c0b8955125bf754614"
],
"model": "Switchgroup",
"name": "Schakel",
"switches": {
"relay": true
},
"vendor": "Plugwise"
},
"d950b314e9d8499f968e6db8d82ef78c": {
"dev_class": "report",
"members": [
"059e4d03c7a34d278add5c7a4a781d19",
"5871317346d045bc9f6b987ef25ee638",
"aac7b735042c4832ac9ff33aae4f453b",
"cfe95cf3de1948c0b8955125bf754614",
"e1c884e7dede431dadee09506ec4f859"
],
"model": "Switchgroup",
"name": "Stroomvreters",
"switches": {
"relay": true
},
"vendor": "Plugwise"
},
"e1c884e7dede431dadee09506ec4f859": {
"dev_class": "refrigerator",
"firmware": "2011-06-27T10:47:37+02:00",
"hardware": "6539-0700-7330",
"location": "0000aaaa0000aaaa0000aaaa0000aa00",
"model": "Circle+ type F",
"name": "Koelkast (92C4A)",
"sensors": {
"electricity_consumed": 50.5,
"electricity_consumed_interval": 0.08,
"electricity_produced": 0.0
},
"switches": {
"lock": false,
"relay": true
},
"vendor": "Plugwise",
"zigbee_mac_address": "0123456789AB"
}
},
"gateway": {
"gateway_id": "0000aaaa0000aaaa0000aaaa0000aa00",
"item_count": 83,
"smile_name": "Stretch"
}
}

View File

@@ -0,0 +1,643 @@
# serializer version: 1
# name: test_diagnostics
dict({
'devices': dict({
'02cf28bfec924855854c544690a609ef': dict({
'available': True,
'dev_class': 'vcr_plug',
'firmware': '2019-06-21T02:00:00+02:00',
'location': 'cd143c07248f491493cea0533bc3d669',
'model': 'Plug',
'model_id': '160-01',
'name': 'NVR',
'sensors': dict({
'electricity_consumed': 34.0,
'electricity_consumed_interval': 9.15,
'electricity_produced': 0.0,
'electricity_produced_interval': 0.0,
}),
'switches': dict({
'lock': True,
'relay': True,
}),
'vendor': 'Plugwise',
'zigbee_mac_address': 'ABCD012345670A15',
}),
'08963fec7c53423ca5680aa4cb502c63': dict({
'active_preset': 'away',
'available_schedules': list([
'CV Roan',
'Bios Schema met Film Avond',
'GF7 Woonkamer',
'Badkamer Schema',
'CV Jessie',
'off',
]),
'climate_mode': 'auto',
'control_state': 'idle',
'dev_class': 'climate',
'model': 'ThermoZone',
'name': 'Badkamer',
'preset_modes': list([
'home',
'asleep',
'away',
'vacation',
'no_frost',
]),
'select_schedule': 'Badkamer Schema',
'sensors': dict({
'temperature': 18.9,
}),
'thermostat': dict({
'lower_bound': 0.0,
'resolution': 0.01,
'setpoint': 14.0,
'upper_bound': 100.0,
}),
'thermostats': dict({
'primary': list([
'f1fee6043d3642a9b0a65297455f008e',
'680423ff840043738f42cc7f1ff97a36',
]),
'secondary': list([
]),
}),
'vendor': 'Plugwise',
}),
'12493538af164a409c6a1c79e38afe1c': dict({
'active_preset': 'away',
'available_schedules': list([
'CV Roan',
'Bios Schema met Film Avond',
'GF7 Woonkamer',
'Badkamer Schema',
'CV Jessie',
'off',
]),
'climate_mode': 'heat',
'control_state': 'idle',
'dev_class': 'climate',
'model': 'ThermoZone',
'name': 'Bios',
'preset_modes': list([
'home',
'asleep',
'away',
'vacation',
'no_frost',
]),
'select_schedule': 'off',
'sensors': dict({
'electricity_consumed': 0.0,
'electricity_produced': 0.0,
'temperature': 16.5,
}),
'thermostat': dict({
'lower_bound': 0.0,
'resolution': 0.01,
'setpoint': 13.0,
'upper_bound': 100.0,
}),
'thermostats': dict({
'primary': list([
'df4a4a8169904cdb9c03d61a21f42140',
]),
'secondary': list([
'a2c3583e0a6349358998b760cea82d2a',
]),
}),
'vendor': 'Plugwise',
}),
'21f2b542c49845e6bb416884c55778d6': dict({
'available': True,
'dev_class': 'game_console_plug',
'firmware': '2019-06-21T02:00:00+02:00',
'location': 'cd143c07248f491493cea0533bc3d669',
'model': 'Plug',
'model_id': '160-01',
'name': 'Playstation Smart Plug',
'sensors': dict({
'electricity_consumed': 84.1,
'electricity_consumed_interval': 8.6,
'electricity_produced': 0.0,
'electricity_produced_interval': 0.0,
}),
'switches': dict({
'lock': False,
'relay': True,
}),
'vendor': 'Plugwise',
'zigbee_mac_address': 'ABCD012345670A12',
}),
'446ac08dd04d4eff8ac57489757b7314': dict({
'active_preset': 'no_frost',
'climate_mode': 'heat',
'control_state': 'idle',
'dev_class': 'climate',
'model': 'ThermoZone',
'name': 'Garage',
'preset_modes': list([
'home',
'asleep',
'away',
'vacation',
'no_frost',
]),
'sensors': dict({
'temperature': 15.6,
}),
'thermostat': dict({
'lower_bound': 0.0,
'resolution': 0.01,
'setpoint': 5.5,
'upper_bound': 100.0,
}),
'thermostats': dict({
'primary': list([
'e7693eb9582644e5b865dba8d4447cf1',
]),
'secondary': list([
]),
}),
'vendor': 'Plugwise',
}),
'4a810418d5394b3f82727340b91ba740': dict({
'available': True,
'dev_class': 'router_plug',
'firmware': '2019-06-21T02:00:00+02:00',
'location': 'cd143c07248f491493cea0533bc3d669',
'model': 'Plug',
'model_id': '160-01',
'name': 'USG Smart Plug',
'sensors': dict({
'electricity_consumed': 8.5,
'electricity_consumed_interval': 0.0,
'electricity_produced': 0.0,
'electricity_produced_interval': 0.0,
}),
'switches': dict({
'lock': True,
'relay': True,
}),
'vendor': 'Plugwise',
'zigbee_mac_address': 'ABCD012345670A16',
}),
'675416a629f343c495449970e2ca37b5': dict({
'available': True,
'dev_class': 'router_plug',
'firmware': '2019-06-21T02:00:00+02:00',
'location': 'cd143c07248f491493cea0533bc3d669',
'model': 'Plug',
'model_id': '160-01',
'name': 'Ziggo Modem',
'sensors': dict({
'electricity_consumed': 12.2,
'electricity_consumed_interval': 2.97,
'electricity_produced': 0.0,
'electricity_produced_interval': 0.0,
}),
'switches': dict({
'lock': True,
'relay': True,
}),
'vendor': 'Plugwise',
'zigbee_mac_address': 'ABCD012345670A01',
}),
'680423ff840043738f42cc7f1ff97a36': dict({
'available': True,
'binary_sensors': dict({
'low_battery': False,
}),
'dev_class': 'thermostatic_radiator_valve',
'firmware': '2019-03-27T01:00:00+01:00',
'hardware': '1',
'location': '08963fec7c53423ca5680aa4cb502c63',
'model': 'Tom/Floor',
'model_id': '106-03',
'name': 'Thermostatic Radiator Badkamer 1',
'sensors': dict({
'battery': 51,
'setpoint': 14.0,
'temperature': 19.1,
'temperature_difference': -0.4,
'valve_position': 0.0,
}),
'temperature_offset': dict({
'lower_bound': -2.0,
'resolution': 0.1,
'setpoint': 0.0,
'upper_bound': 2.0,
}),
'vendor': 'Plugwise',
'zigbee_mac_address': 'ABCD012345670A17',
}),
'6a3bf693d05e48e0b460c815a4fdd09d': dict({
'available': True,
'binary_sensors': dict({
'low_battery': False,
}),
'dev_class': 'zone_thermostat',
'firmware': '2016-10-27T02:00:00+02:00',
'hardware': '255',
'location': '82fa13f017d240daa0d0ea1775420f24',
'model': 'Lisa',
'model_id': '158-01',
'name': 'Zone Thermostat Jessie',
'sensors': dict({
'battery': 37,
'setpoint': 15.0,
'temperature': 17.2,
}),
'temperature_offset': dict({
'lower_bound': -2.0,
'resolution': 0.1,
'setpoint': 0.0,
'upper_bound': 2.0,
}),
'vendor': 'Plugwise',
'zigbee_mac_address': 'ABCD012345670A03',
}),
'78d1126fc4c743db81b61c20e88342a7': dict({
'available': True,
'dev_class': 'central_heating_pump_plug',
'firmware': '2019-06-21T02:00:00+02:00',
'location': 'c50f167537524366a5af7aa3942feb1e',
'model': 'Plug',
'model_id': '160-01',
'name': 'CV Pomp',
'sensors': dict({
'electricity_consumed': 35.6,
'electricity_consumed_interval': 7.37,
'electricity_produced': 0.0,
'electricity_produced_interval': 0.0,
}),
'switches': dict({
'relay': True,
}),
'vendor': 'Plugwise',
'zigbee_mac_address': 'ABCD012345670A05',
}),
'82fa13f017d240daa0d0ea1775420f24': dict({
'active_preset': 'asleep',
'available_schedules': list([
'CV Roan',
'Bios Schema met Film Avond',
'GF7 Woonkamer',
'Badkamer Schema',
'CV Jessie',
'off',
]),
'climate_mode': 'auto',
'control_state': 'idle',
'dev_class': 'climate',
'model': 'ThermoZone',
'name': 'Jessie',
'preset_modes': list([
'home',
'asleep',
'away',
'vacation',
'no_frost',
]),
'select_schedule': 'CV Jessie',
'sensors': dict({
'temperature': 17.2,
}),
'thermostat': dict({
'lower_bound': 0.0,
'resolution': 0.01,
'setpoint': 15.0,
'upper_bound': 100.0,
}),
'thermostats': dict({
'primary': list([
'6a3bf693d05e48e0b460c815a4fdd09d',
]),
'secondary': list([
'd3da73bde12a47d5a6b8f9dad971f2ec',
]),
}),
'vendor': 'Plugwise',
}),
'90986d591dcd426cae3ec3e8111ff730': dict({
'binary_sensors': dict({
'heating_state': True,
}),
'dev_class': 'heater_central',
'location': '1f9dcf83fd4e4b66b72ff787957bfe5d',
'model': 'Unknown',
'name': 'OnOff',
'sensors': dict({
'intended_boiler_temperature': 70.0,
'modulation_level': 1,
'water_temperature': 70.0,
}),
}),
'a28f588dc4a049a483fd03a30361ad3a': dict({
'available': True,
'dev_class': 'settop_plug',
'firmware': '2019-06-21T02:00:00+02:00',
'location': 'cd143c07248f491493cea0533bc3d669',
'model': 'Plug',
'model_id': '160-01',
'name': 'Fibaro HC2',
'sensors': dict({
'electricity_consumed': 12.5,
'electricity_consumed_interval': 3.8,
'electricity_produced': 0.0,
'electricity_produced_interval': 0.0,
}),
'switches': dict({
'lock': True,
'relay': True,
}),
'vendor': 'Plugwise',
'zigbee_mac_address': 'ABCD012345670A13',
}),
'a2c3583e0a6349358998b760cea82d2a': dict({
'available': True,
'binary_sensors': dict({
'low_battery': False,
}),
'dev_class': 'thermostatic_radiator_valve',
'firmware': '2019-03-27T01:00:00+01:00',
'hardware': '1',
'location': '12493538af164a409c6a1c79e38afe1c',
'model': 'Tom/Floor',
'model_id': '106-03',
'name': 'Bios Cv Thermostatic Radiator ',
'sensors': dict({
'battery': 62,
'setpoint': 13.0,
'temperature': 17.2,
'temperature_difference': -0.2,
'valve_position': 0.0,
}),
'temperature_offset': dict({
'lower_bound': -2.0,
'resolution': 0.1,
'setpoint': 0.0,
'upper_bound': 2.0,
}),
'vendor': 'Plugwise',
'zigbee_mac_address': 'ABCD012345670A09',
}),
'b310b72a0e354bfab43089919b9a88bf': dict({
'available': True,
'dev_class': 'thermostatic_radiator_valve',
'firmware': '2019-03-27T01:00:00+01:00',
'hardware': '1',
'location': 'c50f167537524366a5af7aa3942feb1e',
'model': 'Tom/Floor',
'model_id': '106-03',
'name': 'Floor kraan',
'sensors': dict({
'setpoint': 21.5,
'temperature': 26.0,
'temperature_difference': 3.5,
'valve_position': 100,
}),
'temperature_offset': dict({
'lower_bound': -2.0,
'resolution': 0.1,
'setpoint': 0.0,
'upper_bound': 2.0,
}),
'vendor': 'Plugwise',
'zigbee_mac_address': 'ABCD012345670A02',
}),
'b59bcebaf94b499ea7d46e4a66fb62d8': dict({
'available': True,
'binary_sensors': dict({
'low_battery': False,
}),
'dev_class': 'zone_thermostat',
'firmware': '2016-08-02T02:00:00+02:00',
'hardware': '255',
'location': 'c50f167537524366a5af7aa3942feb1e',
'model': 'Lisa',
'model_id': '158-01',
'name': 'Zone Lisa WK',
'sensors': dict({
'battery': 34,
'setpoint': 21.5,
'temperature': 20.9,
}),
'temperature_offset': dict({
'lower_bound': -2.0,
'resolution': 0.1,
'setpoint': 0.0,
'upper_bound': 2.0,
}),
'vendor': 'Plugwise',
'zigbee_mac_address': 'ABCD012345670A07',
}),
'c50f167537524366a5af7aa3942feb1e': dict({
'active_preset': 'home',
'available_schedules': list([
'CV Roan',
'Bios Schema met Film Avond',
'GF7 Woonkamer',
'Badkamer Schema',
'CV Jessie',
'off',
]),
'climate_mode': 'auto',
'control_state': 'heating',
'dev_class': 'climate',
'model': 'ThermoZone',
'name': 'Woonkamer',
'preset_modes': list([
'home',
'asleep',
'away',
'vacation',
'no_frost',
]),
'select_schedule': 'GF7 Woonkamer',
'sensors': dict({
'electricity_consumed': 35.6,
'electricity_produced': 0.0,
'temperature': 20.9,
}),
'thermostat': dict({
'lower_bound': 0.0,
'resolution': 0.01,
'setpoint': 21.5,
'upper_bound': 100.0,
}),
'thermostats': dict({
'primary': list([
'b59bcebaf94b499ea7d46e4a66fb62d8',
]),
'secondary': list([
'b310b72a0e354bfab43089919b9a88bf',
]),
}),
'vendor': 'Plugwise',
}),
'cd0ddb54ef694e11ac18ed1cbce5dbbd': dict({
'available': True,
'dev_class': 'vcr_plug',
'firmware': '2019-06-21T02:00:00+02:00',
'location': 'cd143c07248f491493cea0533bc3d669',
'model': 'Plug',
'model_id': '160-01',
'name': 'NAS',
'sensors': dict({
'electricity_consumed': 16.5,
'electricity_consumed_interval': 0.5,
'electricity_produced': 0.0,
'electricity_produced_interval': 0.0,
}),
'switches': dict({
'lock': True,
'relay': True,
}),
'vendor': 'Plugwise',
'zigbee_mac_address': 'ABCD012345670A14',
}),
'd3da73bde12a47d5a6b8f9dad971f2ec': dict({
'available': True,
'binary_sensors': dict({
'low_battery': False,
}),
'dev_class': 'thermostatic_radiator_valve',
'firmware': '2019-03-27T01:00:00+01:00',
'hardware': '1',
'location': '82fa13f017d240daa0d0ea1775420f24',
'model': 'Tom/Floor',
'model_id': '106-03',
'name': 'Thermostatic Radiator Jessie',
'sensors': dict({
'battery': 62,
'setpoint': 15.0,
'temperature': 17.1,
'temperature_difference': 0.1,
'valve_position': 0.0,
}),
'temperature_offset': dict({
'lower_bound': -2.0,
'resolution': 0.1,
'setpoint': 0.0,
'upper_bound': 2.0,
}),
'vendor': 'Plugwise',
'zigbee_mac_address': 'ABCD012345670A10',
}),
'df4a4a8169904cdb9c03d61a21f42140': dict({
'available': True,
'binary_sensors': dict({
'low_battery': False,
}),
'dev_class': 'zone_thermostat',
'firmware': '2016-10-27T02:00:00+02:00',
'hardware': '255',
'location': '12493538af164a409c6a1c79e38afe1c',
'model': 'Lisa',
'model_id': '158-01',
'name': 'Zone Lisa Bios',
'sensors': dict({
'battery': 67,
'setpoint': 13.0,
'temperature': 16.5,
}),
'temperature_offset': dict({
'lower_bound': -2.0,
'resolution': 0.1,
'setpoint': 0.0,
'upper_bound': 2.0,
}),
'vendor': 'Plugwise',
'zigbee_mac_address': 'ABCD012345670A06',
}),
'e7693eb9582644e5b865dba8d4447cf1': dict({
'available': True,
'binary_sensors': dict({
'low_battery': False,
}),
'dev_class': 'thermostatic_radiator_valve',
'firmware': '2019-03-27T01:00:00+01:00',
'hardware': '1',
'location': '446ac08dd04d4eff8ac57489757b7314',
'model': 'Tom/Floor',
'model_id': '106-03',
'name': 'CV Kraan Garage',
'sensors': dict({
'battery': 68,
'setpoint': 5.5,
'temperature': 15.6,
'temperature_difference': 0.0,
'valve_position': 0.0,
}),
'temperature_offset': dict({
'lower_bound': -2.0,
'resolution': 0.1,
'setpoint': 0.0,
'upper_bound': 2.0,
}),
'vendor': 'Plugwise',
'zigbee_mac_address': 'ABCD012345670A11',
}),
'f1fee6043d3642a9b0a65297455f008e': dict({
'available': True,
'binary_sensors': dict({
'low_battery': False,
}),
'dev_class': 'thermostatic_radiator_valve',
'firmware': '2016-10-27T02:00:00+02:00',
'hardware': '255',
'location': '08963fec7c53423ca5680aa4cb502c63',
'model': 'Lisa',
'model_id': '158-01',
'name': 'Thermostatic Radiator Badkamer 2',
'sensors': dict({
'battery': 92,
'setpoint': 14.0,
'temperature': 18.9,
}),
'temperature_offset': dict({
'lower_bound': -2.0,
'resolution': 0.1,
'setpoint': 0.0,
'upper_bound': 2.0,
}),
'vendor': 'Plugwise',
'zigbee_mac_address': 'ABCD012345670A08',
}),
'fe799307f1624099878210aa0b9f1475': dict({
'binary_sensors': dict({
'plugwise_notification': True,
}),
'dev_class': 'gateway',
'firmware': '3.0.15',
'hardware': 'AME Smile 2.0 board',
'location': '1f9dcf83fd4e4b66b72ff787957bfe5d',
'mac_address': '012345670001',
'model': 'Gateway',
'model_id': 'smile_open_therm',
'name': 'Adam',
'select_regulation_mode': 'heating',
'sensors': dict({
'outdoor_temperature': 7.81,
}),
'vendor': 'Plugwise',
'zigbee_mac_address': 'ABCD012345670101',
}),
}),
'gateway': dict({
'cooling_present': False,
'gateway_id': 'fe799307f1624099878210aa0b9f1475',
'heater_id': '90986d591dcd426cae3ec3e8111ff730',
'item_count': 369,
'notifications': dict({
'af82e4ccf9c548528166d38e560662a4': dict({
'warning': "Node Plug (with MAC address 000D6F000D13CB01, in room 'n.a.') has been unreachable since 23:03 2020-01-18. Please check the connection and restart the device.",
}),
}),
'reboot': True,
'smile_name': 'Adam',
}),
})
# ---

View File

@@ -0,0 +1,77 @@
"""Tests for the Plugwise binary_sensor integration."""
from unittest.mock import MagicMock
from homeassistant.const import STATE_OFF, STATE_ON
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_component import async_update_entity
from tests.common import MockConfigEntry
async def test_anna_climate_binary_sensor_entities(
hass: HomeAssistant, mock_smile_anna: MagicMock, init_integration: MockConfigEntry
) -> None:
"""Test creation of climate related binary_sensor entities."""
state = hass.states.get("binary_sensor.opentherm_secondary_boiler_state")
assert state
assert state.state == STATE_OFF
state = hass.states.get("binary_sensor.opentherm_dhw_state")
assert state
assert state.state == STATE_OFF
state = hass.states.get("binary_sensor.opentherm_heating")
assert state
assert state.state == STATE_ON
state = hass.states.get("binary_sensor.opentherm_cooling_enabled")
assert state
assert state.state == STATE_OFF
state = hass.states.get("binary_sensor.opentherm_compressor_state")
assert state
assert state.state == STATE_ON
async def test_anna_climate_binary_sensor_change(
hass: HomeAssistant, mock_smile_anna: MagicMock, init_integration: MockConfigEntry
) -> None:
"""Test change of climate related binary_sensor entities."""
hass.states.async_set("binary_sensor.opentherm_dhw_state", STATE_ON, {})
await hass.async_block_till_done()
state = hass.states.get("binary_sensor.opentherm_dhw_state")
assert state
assert state.state == STATE_ON
await async_update_entity(hass, "binary_sensor.opentherm_dhw_state")
state = hass.states.get("binary_sensor.opentherm_dhw_state")
assert state
assert state.state == STATE_OFF
async def test_adam_climate_binary_sensor_change(
hass: HomeAssistant, mock_smile_adam: MagicMock, init_integration: MockConfigEntry
) -> None:
"""Test of a climate related plugwise-notification binary_sensor."""
state = hass.states.get("binary_sensor.adam_plugwise_notification")
assert state
assert state.state == STATE_ON
assert "warning_msg" in state.attributes
assert "unreachable" in state.attributes["warning_msg"][0]
assert not state.attributes.get("error_msg")
assert not state.attributes.get("other_msg")
async def test_p1_v4_binary_sensor_entity(
hass: HomeAssistant, mock_smile_p1_2: MagicMock, init_integration: MockConfigEntry
) -> None:
"""Test of a Smile P1 related plugwise-notification binary_sensor."""
state = hass.states.get("binary_sensor.smile_p1_plugwise_notification")
assert state
assert state.state == STATE_ON
assert "warning_msg" in state.attributes
assert "connected" in state.attributes["warning_msg"][0]

View File

@@ -0,0 +1,39 @@
"""Tests for Plugwise button entities."""
from unittest.mock import MagicMock
from homeassistant.components.button import (
DOMAIN as BUTTON_DOMAIN,
SERVICE_PRESS,
ButtonDeviceClass,
)
from homeassistant.const import ATTR_DEVICE_CLASS, ATTR_ENTITY_ID, STATE_UNKNOWN
from homeassistant.core import HomeAssistant
from homeassistant.helpers import entity_registry as er
from tests.common import MockConfigEntry
async def test_adam_reboot_button(
hass: HomeAssistant, mock_smile_adam: MagicMock, init_integration: MockConfigEntry
) -> None:
"""Test creation of button entities."""
state = hass.states.get("button.adam_reboot")
assert state
assert state.state == STATE_UNKNOWN
assert state.attributes.get(ATTR_DEVICE_CLASS) == ButtonDeviceClass.RESTART
registry = er.async_get(hass)
entry = registry.async_get("button.adam_reboot")
assert entry
assert entry.unique_id == "fe799307f1624099878210aa0b9f1475-reboot"
await hass.services.async_call(
BUTTON_DOMAIN,
SERVICE_PRESS,
{ATTR_ENTITY_ID: "button.adam_reboot"},
blocking=True,
)
assert mock_smile_adam.reboot_gateway.call_count == 1
mock_smile_adam.reboot_gateway.assert_called_with()

View File

@@ -0,0 +1,444 @@
"""Tests for the Plugwise Climate integration."""
from datetime import timedelta
from unittest.mock import MagicMock, patch
from freezegun.api import FrozenDateTimeFactory
from plugwise.exceptions import PlugwiseError
import pytest
from homeassistant.components.climate import (
ATTR_CURRENT_TEMPERATURE,
ATTR_HVAC_ACTION,
ATTR_HVAC_MODE,
ATTR_HVAC_MODES,
ATTR_MAX_TEMP,
ATTR_MIN_TEMP,
ATTR_PRESET_MODE,
ATTR_PRESET_MODES,
ATTR_TARGET_TEMP_HIGH,
ATTR_TARGET_TEMP_LOW,
ATTR_TARGET_TEMP_STEP,
DOMAIN as CLIMATE_DOMAIN,
PRESET_AWAY,
PRESET_HOME,
SERVICE_SET_HVAC_MODE,
SERVICE_SET_PRESET_MODE,
SERVICE_SET_TEMPERATURE,
HVACAction,
HVACMode,
)
from homeassistant.const import (
ATTR_ENTITY_ID,
ATTR_SUPPORTED_FEATURES,
ATTR_TEMPERATURE,
)
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import HomeAssistantError, ServiceValidationError
from tests.common import MockConfigEntry, async_fire_time_changed
HA_PLUGWISE_SMILE_ASYNC_UPDATE = (
"homeassistant.components.plugwise.coordinator.Smile.async_update"
)
async def test_adam_climate_entity_attributes(
hass: HomeAssistant, mock_smile_adam: MagicMock, init_integration: MockConfigEntry
) -> None:
"""Test creation of adam climate device environment."""
state = hass.states.get("climate.woonkamer")
assert state
assert state.state == HVACMode.AUTO
assert state.attributes[ATTR_HVAC_ACTION] == HVACAction.HEATING
assert state.attributes[ATTR_HVAC_MODES] == [HVACMode.AUTO, HVACMode.HEAT]
assert ATTR_PRESET_MODES in state.attributes
assert "no_frost" in state.attributes[ATTR_PRESET_MODES]
assert PRESET_HOME in state.attributes[ATTR_PRESET_MODES]
assert state.attributes[ATTR_PRESET_MODE] == PRESET_HOME
assert state.attributes[ATTR_CURRENT_TEMPERATURE] == 20.9
assert state.attributes[ATTR_SUPPORTED_FEATURES] == 17
assert state.attributes[ATTR_TEMPERATURE] == 21.5
assert state.attributes[ATTR_MIN_TEMP] == 0.0
assert state.attributes[ATTR_MAX_TEMP] == 35.0
assert state.attributes[ATTR_TARGET_TEMP_STEP] == 0.1
state = hass.states.get("climate.jessie")
assert state
assert state.state == HVACMode.AUTO
assert state.attributes[ATTR_HVAC_ACTION] == HVACAction.IDLE
assert state.attributes[ATTR_HVAC_MODES] == [HVACMode.AUTO, HVACMode.HEAT]
assert ATTR_PRESET_MODES in state.attributes
assert "no_frost" in state.attributes[ATTR_PRESET_MODES]
assert PRESET_HOME in state.attributes[ATTR_PRESET_MODES]
assert state.attributes[ATTR_PRESET_MODE] == "asleep"
assert state.attributes[ATTR_CURRENT_TEMPERATURE] == 17.2
assert state.attributes[ATTR_TEMPERATURE] == 15.0
assert state.attributes[ATTR_MIN_TEMP] == 0.0
assert state.attributes[ATTR_MAX_TEMP] == 35.0
assert state.attributes[ATTR_TARGET_TEMP_STEP] == 0.1
async def test_adam_2_climate_entity_attributes(
hass: HomeAssistant, mock_smile_adam_2: MagicMock, init_integration: MockConfigEntry
) -> None:
"""Test creation of adam climate device environment."""
state = hass.states.get("climate.living_room")
assert state
assert state.state == HVACMode.HEAT
assert state.attributes[ATTR_HVAC_ACTION] == HVACAction.PREHEATING
assert state.attributes[ATTR_HVAC_MODES] == [
HVACMode.OFF,
HVACMode.AUTO,
HVACMode.HEAT,
]
state = hass.states.get("climate.bathroom")
assert state
assert state.state == HVACMode.AUTO
assert state.attributes[ATTR_HVAC_ACTION] == HVACAction.IDLE
assert state.attributes[ATTR_HVAC_MODES] == [
HVACMode.OFF,
HVACMode.AUTO,
HVACMode.HEAT,
]
async def test_adam_3_climate_entity_attributes(
hass: HomeAssistant,
mock_smile_adam_3: MagicMock,
init_integration: MockConfigEntry,
freezer: FrozenDateTimeFactory,
) -> None:
"""Test creation of adam climate device environment."""
state = hass.states.get("climate.living_room")
assert state
assert state.state == HVACMode.COOL
assert state.attributes[ATTR_HVAC_ACTION] == HVACAction.COOLING
assert state.attributes[ATTR_HVAC_MODES] == [
HVACMode.OFF,
HVACMode.AUTO,
HVACMode.COOL,
]
data = mock_smile_adam_3.async_update.return_value
data.devices["da224107914542988a88561b4452b0f6"]["select_regulation_mode"] = (
"heating"
)
data.devices["f2bf9048bef64cc5b6d5110154e33c81"]["control_state"] = (
HVACAction.HEATING
)
data.devices["056ee145a816487eaa69243c3280f8bf"]["binary_sensors"][
"cooling_state"
] = False
data.devices["056ee145a816487eaa69243c3280f8bf"]["binary_sensors"][
"heating_state"
] = True
with patch(HA_PLUGWISE_SMILE_ASYNC_UPDATE, return_value=data):
freezer.tick(timedelta(minutes=1))
async_fire_time_changed(hass)
await hass.async_block_till_done()
state = hass.states.get("climate.living_room")
assert state
assert state.state == HVACMode.HEAT
assert state.attributes[ATTR_HVAC_ACTION] == HVACAction.HEATING
assert state.attributes[ATTR_HVAC_MODES] == [
HVACMode.OFF,
HVACMode.AUTO,
HVACMode.HEAT,
]
data = mock_smile_adam_3.async_update.return_value
data.devices["da224107914542988a88561b4452b0f6"]["select_regulation_mode"] = (
"cooling"
)
data.devices["f2bf9048bef64cc5b6d5110154e33c81"]["control_state"] = (
HVACAction.COOLING
)
data.devices["056ee145a816487eaa69243c3280f8bf"]["binary_sensors"][
"cooling_state"
] = True
data.devices["056ee145a816487eaa69243c3280f8bf"]["binary_sensors"][
"heating_state"
] = False
with patch(HA_PLUGWISE_SMILE_ASYNC_UPDATE, return_value=data):
freezer.tick(timedelta(minutes=1))
async_fire_time_changed(hass)
await hass.async_block_till_done()
state = hass.states.get("climate.living_room")
assert state
assert state.state == HVACMode.COOL
assert state.attributes[ATTR_HVAC_ACTION] == HVACAction.COOLING
assert state.attributes[ATTR_HVAC_MODES] == [
HVACMode.OFF,
HVACMode.AUTO,
HVACMode.COOL,
]
async def test_adam_climate_adjust_negative_testing(
hass: HomeAssistant, mock_smile_adam: MagicMock, init_integration: MockConfigEntry
) -> None:
"""Test PlugwiseError exception."""
mock_smile_adam.set_temperature.side_effect = PlugwiseError
with pytest.raises(HomeAssistantError):
await hass.services.async_call(
CLIMATE_DOMAIN,
SERVICE_SET_TEMPERATURE,
{ATTR_ENTITY_ID: "climate.woonkamer", ATTR_TEMPERATURE: 25},
blocking=True,
)
async def test_adam_climate_entity_climate_changes(
hass: HomeAssistant, mock_smile_adam: MagicMock, init_integration: MockConfigEntry
) -> None:
"""Test handling of user requests in adam climate device environment."""
await hass.services.async_call(
CLIMATE_DOMAIN,
SERVICE_SET_TEMPERATURE,
{ATTR_ENTITY_ID: "climate.woonkamer", ATTR_TEMPERATURE: 25},
blocking=True,
)
assert mock_smile_adam.set_temperature.call_count == 1
mock_smile_adam.set_temperature.assert_called_with(
"c50f167537524366a5af7aa3942feb1e", {"setpoint": 25.0}
)
await hass.services.async_call(
CLIMATE_DOMAIN,
SERVICE_SET_TEMPERATURE,
{
ATTR_ENTITY_ID: "climate.woonkamer",
ATTR_HVAC_MODE: HVACMode.HEAT,
ATTR_TEMPERATURE: 25,
},
blocking=True,
)
assert mock_smile_adam.set_temperature.call_count == 2
mock_smile_adam.set_temperature.assert_called_with(
"c50f167537524366a5af7aa3942feb1e", {"setpoint": 25.0}
)
with pytest.raises(ServiceValidationError, match="Accepted range"):
await hass.services.async_call(
CLIMATE_DOMAIN,
SERVICE_SET_TEMPERATURE,
{ATTR_ENTITY_ID: "climate.woonkamer", ATTR_TEMPERATURE: 150},
blocking=True,
)
await hass.services.async_call(
CLIMATE_DOMAIN,
SERVICE_SET_PRESET_MODE,
{ATTR_ENTITY_ID: "climate.woonkamer", ATTR_PRESET_MODE: PRESET_AWAY},
blocking=True,
)
assert mock_smile_adam.set_preset.call_count == 1
mock_smile_adam.set_preset.assert_called_with(
"c50f167537524366a5af7aa3942feb1e", PRESET_AWAY
)
await hass.services.async_call(
CLIMATE_DOMAIN,
SERVICE_SET_HVAC_MODE,
{ATTR_ENTITY_ID: "climate.woonkamer", ATTR_HVAC_MODE: HVACMode.HEAT},
blocking=True,
)
assert mock_smile_adam.set_schedule_state.call_count == 2
mock_smile_adam.set_schedule_state.assert_called_with(
"c50f167537524366a5af7aa3942feb1e", HVACMode.OFF
)
with pytest.raises(ServiceValidationError, match="valid modes are"):
await hass.services.async_call(
CLIMATE_DOMAIN,
SERVICE_SET_HVAC_MODE,
{
ATTR_ENTITY_ID: "climate.jessie",
ATTR_HVAC_MODE: HVACMode.DRY,
},
blocking=True,
)
async def test_adam_climate_off_mode_change(
hass: HomeAssistant,
mock_smile_adam_4: MagicMock,
init_integration: MockConfigEntry,
) -> None:
"""Test handling of user requests in adam climate device environment."""
state = hass.states.get("climate.slaapkamer")
assert state
assert state.state == HVACMode.OFF
await hass.services.async_call(
CLIMATE_DOMAIN,
SERVICE_SET_HVAC_MODE,
{
ATTR_ENTITY_ID: "climate.slaapkamer",
ATTR_HVAC_MODE: HVACMode.HEAT,
},
blocking=True,
)
assert mock_smile_adam_4.set_schedule_state.call_count == 1
assert mock_smile_adam_4.set_regulation_mode.call_count == 1
mock_smile_adam_4.set_regulation_mode.assert_called_with("heating")
state = hass.states.get("climate.kinderkamer")
assert state
assert state.state == HVACMode.HEAT
await hass.services.async_call(
CLIMATE_DOMAIN,
SERVICE_SET_HVAC_MODE,
{
ATTR_ENTITY_ID: "climate.kinderkamer",
ATTR_HVAC_MODE: HVACMode.OFF,
},
blocking=True,
)
assert mock_smile_adam_4.set_schedule_state.call_count == 1
assert mock_smile_adam_4.set_regulation_mode.call_count == 2
mock_smile_adam_4.set_regulation_mode.assert_called_with("off")
state = hass.states.get("climate.logeerkamer")
assert state
assert state.state == HVACMode.HEAT
await hass.services.async_call(
CLIMATE_DOMAIN,
SERVICE_SET_HVAC_MODE,
{
ATTR_ENTITY_ID: "climate.logeerkamer",
ATTR_HVAC_MODE: HVACMode.HEAT,
},
blocking=True,
)
assert mock_smile_adam_4.set_schedule_state.call_count == 1
assert mock_smile_adam_4.set_regulation_mode.call_count == 2
async def test_anna_climate_entity_attributes(
hass: HomeAssistant,
mock_smile_anna: MagicMock,
init_integration: MockConfigEntry,
) -> None:
"""Test creation of anna climate device environment."""
state = hass.states.get("climate.anna")
assert state
assert state.state == HVACMode.AUTO
assert state.attributes[ATTR_HVAC_ACTION] == HVACAction.HEATING
assert state.attributes[ATTR_HVAC_MODES] == [HVACMode.AUTO, HVACMode.HEAT_COOL]
assert "no_frost" in state.attributes[ATTR_PRESET_MODES]
assert PRESET_HOME in state.attributes[ATTR_PRESET_MODES]
assert state.attributes[ATTR_CURRENT_TEMPERATURE] == 19.3
assert state.attributes[ATTR_PRESET_MODE] == PRESET_HOME
assert state.attributes[ATTR_SUPPORTED_FEATURES] == 18
assert state.attributes[ATTR_TARGET_TEMP_HIGH] == 30
assert state.attributes[ATTR_TARGET_TEMP_LOW] == 20.5
assert state.attributes[ATTR_MIN_TEMP] == 4
assert state.attributes[ATTR_MAX_TEMP] == 30
assert state.attributes[ATTR_TARGET_TEMP_STEP] == 0.1
async def test_anna_2_climate_entity_attributes(
hass: HomeAssistant,
mock_smile_anna_2: MagicMock,
init_integration: MockConfigEntry,
) -> None:
"""Test creation of anna climate device environment."""
state = hass.states.get("climate.anna")
assert state
assert state.state == HVACMode.AUTO
assert state.attributes[ATTR_HVAC_ACTION] == HVACAction.COOLING
assert state.attributes[ATTR_HVAC_MODES] == [
HVACMode.AUTO,
HVACMode.HEAT_COOL,
]
assert state.attributes[ATTR_SUPPORTED_FEATURES] == 18
assert state.attributes[ATTR_TARGET_TEMP_HIGH] == 30
assert state.attributes[ATTR_TARGET_TEMP_LOW] == 20.5
async def test_anna_3_climate_entity_attributes(
hass: HomeAssistant,
mock_smile_anna_3: MagicMock,
init_integration: MockConfigEntry,
) -> None:
"""Test creation of anna climate device environment."""
state = hass.states.get("climate.anna")
assert state
assert state.state == HVACMode.AUTO
assert state.attributes[ATTR_HVAC_ACTION] == HVACAction.IDLE
assert state.attributes[ATTR_HVAC_MODES] == [
HVACMode.AUTO,
HVACMode.HEAT_COOL,
]
async def test_anna_climate_entity_climate_changes(
hass: HomeAssistant,
mock_smile_anna: MagicMock,
init_integration: MockConfigEntry,
freezer: FrozenDateTimeFactory,
) -> None:
"""Test handling of user requests in anna climate device environment."""
await hass.services.async_call(
CLIMATE_DOMAIN,
SERVICE_SET_TEMPERATURE,
{
ATTR_ENTITY_ID: "climate.anna",
ATTR_TARGET_TEMP_HIGH: 30,
ATTR_TARGET_TEMP_LOW: 20,
},
blocking=True,
)
assert mock_smile_anna.set_temperature.call_count == 1
mock_smile_anna.set_temperature.assert_called_with(
"c784ee9fdab44e1395b8dee7d7a497d5",
{"setpoint_high": 30.0, "setpoint_low": 20.0},
)
await hass.services.async_call(
CLIMATE_DOMAIN,
SERVICE_SET_PRESET_MODE,
{ATTR_ENTITY_ID: "climate.anna", ATTR_PRESET_MODE: PRESET_AWAY},
blocking=True,
)
assert mock_smile_anna.set_preset.call_count == 1
mock_smile_anna.set_preset.assert_called_with(
"c784ee9fdab44e1395b8dee7d7a497d5", PRESET_AWAY
)
await hass.services.async_call(
CLIMATE_DOMAIN,
SERVICE_SET_HVAC_MODE,
{ATTR_ENTITY_ID: "climate.anna", ATTR_HVAC_MODE: HVACMode.AUTO},
blocking=True,
)
# hvac_mode is already auto so not called.
assert mock_smile_anna.set_schedule_state.call_count == 0
await hass.services.async_call(
CLIMATE_DOMAIN,
SERVICE_SET_HVAC_MODE,
{ATTR_ENTITY_ID: "climate.anna", ATTR_HVAC_MODE: HVACMode.HEAT_COOL},
blocking=True,
)
assert mock_smile_anna.set_schedule_state.call_count == 1
mock_smile_anna.set_schedule_state.assert_called_with(
"c784ee9fdab44e1395b8dee7d7a497d5", HVACMode.OFF
)
data = mock_smile_anna.async_update.return_value
data.devices["3cb70739631c4d17a86b8b12e8a5161b"].pop("available_schedules")
with patch(HA_PLUGWISE_SMILE_ASYNC_UPDATE, return_value=data):
freezer.tick(timedelta(minutes=1))
async_fire_time_changed(hass)
await hass.async_block_till_done()
state = hass.states.get("climate.anna")
assert state.state == HVACMode.HEAT
assert state.attributes[ATTR_HVAC_MODES] == [HVACMode.HEAT_COOL]

View File

@@ -0,0 +1,526 @@
"""Test the Plugwise config flow."""
from ipaddress import ip_address
from unittest.mock import AsyncMock, MagicMock
from plugwise.exceptions import (
ConnectionFailedError,
InvalidAuthentication,
InvalidSetupError,
InvalidXMLError,
UnsupportedDeviceError,
)
import pytest
from homeassistant.components.plugwise.const import DEFAULT_PORT, DOMAIN
from homeassistant.components.zeroconf import ZeroconfServiceInfo
from homeassistant.config_entries import SOURCE_USER, SOURCE_ZEROCONF, ConfigFlowResult
from homeassistant.const import (
CONF_HOST,
CONF_NAME,
CONF_PASSWORD,
CONF_PORT,
CONF_SOURCE,
CONF_USERNAME,
)
from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
from tests.common import MockConfigEntry
TEST_HOST = "1.1.1.1"
TEST_HOSTNAME = "smileabcdef"
TEST_HOSTNAME2 = "stretchabc"
TEST_PASSWORD = "test_password"
TEST_PORT = 81
TEST_USERNAME = "smile"
TEST_USERNAME2 = "stretch"
TEST_SMILE_HOST = "smile12345"
TEST_DISCOVERY = ZeroconfServiceInfo(
ip_address=ip_address(TEST_HOST),
ip_addresses=[ip_address(TEST_HOST)],
# The added `-2` is to simulate mDNS collision
hostname=f"{TEST_HOSTNAME}-2.local.",
name="mock_name",
port=DEFAULT_PORT,
properties={
"product": "smile",
"version": "1.2.3",
"hostname": f"{TEST_HOSTNAME}.local.",
},
type="mock_type",
)
TEST_DISCOVERY2 = ZeroconfServiceInfo(
ip_address=ip_address(TEST_HOST),
ip_addresses=[ip_address(TEST_HOST)],
hostname=f"{TEST_HOSTNAME2}.local.",
name="mock_name",
port=DEFAULT_PORT,
properties={
"product": "stretch",
"version": "1.2.3",
"hostname": f"{TEST_HOSTNAME2}.local.",
},
type="mock_type",
)
TEST_DISCOVERY_ANNA = ZeroconfServiceInfo(
ip_address=ip_address(TEST_HOST),
ip_addresses=[ip_address(TEST_HOST)],
hostname=f"{TEST_HOSTNAME}.local.",
name="mock_name",
port=DEFAULT_PORT,
properties={
"product": "smile_thermo",
"version": "1.2.3",
"hostname": f"{TEST_HOSTNAME}.local.",
},
type="mock_type",
)
TEST_DISCOVERY_ADAM = ZeroconfServiceInfo(
ip_address=ip_address(TEST_HOST),
ip_addresses=[ip_address(TEST_HOST)],
hostname=f"{TEST_HOSTNAME2}.local.",
name="mock_name",
port=DEFAULT_PORT,
properties={
"product": "smile_open_therm",
"version": "1.2.3",
"hostname": f"{TEST_HOSTNAME2}.local.",
},
type="mock_type",
)
async def test_form(
hass: HomeAssistant,
mock_setup_entry: AsyncMock,
mock_smile_config_flow: MagicMock,
) -> None:
"""Test the full user configuration flow."""
result = await hass.config_entries.flow.async_init(
DOMAIN, context={CONF_SOURCE: SOURCE_USER}
)
assert result.get("type") is FlowResultType.FORM
assert result.get("errors") == {}
assert result.get("step_id") == "user"
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"],
user_input={
CONF_HOST: TEST_HOST,
CONF_PASSWORD: TEST_PASSWORD,
},
)
await hass.async_block_till_done()
assert result2.get("type") is FlowResultType.CREATE_ENTRY
assert result2.get("title") == "Test Smile Name"
assert result2.get("data") == {
CONF_HOST: TEST_HOST,
CONF_PASSWORD: TEST_PASSWORD,
CONF_PORT: DEFAULT_PORT,
CONF_USERNAME: TEST_USERNAME,
}
assert len(mock_setup_entry.mock_calls) == 1
assert len(mock_smile_config_flow.connect.mock_calls) == 1
assert result2["result"].unique_id == TEST_SMILE_HOST
@pytest.mark.parametrize(
("discovery", "username"),
[
(TEST_DISCOVERY, TEST_USERNAME),
(TEST_DISCOVERY2, TEST_USERNAME2),
],
)
async def test_zeroconf_flow(
hass: HomeAssistant,
mock_setup_entry: AsyncMock,
mock_smile_config_flow: MagicMock,
discovery: ZeroconfServiceInfo,
username: str,
) -> None:
"""Test config flow for smile devices."""
result = await hass.config_entries.flow.async_init(
DOMAIN,
context={CONF_SOURCE: SOURCE_ZEROCONF},
data=TEST_DISCOVERY,
)
assert result.get("type") is FlowResultType.FORM
assert result.get("errors") == {}
assert result.get("step_id") == "user"
assert "flow_id" in result
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"],
user_input={CONF_PASSWORD: TEST_PASSWORD},
)
await hass.async_block_till_done()
assert result2.get("type") is FlowResultType.CREATE_ENTRY
assert result2.get("title") == "Test Smile Name"
assert result2.get("data") == {
CONF_HOST: TEST_HOST,
CONF_PASSWORD: TEST_PASSWORD,
CONF_PORT: DEFAULT_PORT,
CONF_USERNAME: TEST_USERNAME,
}
assert len(mock_setup_entry.mock_calls) == 1
assert len(mock_smile_config_flow.connect.mock_calls) == 1
assert result2["result"].unique_id == TEST_SMILE_HOST
async def test_zeroconf_flow_stretch(
hass: HomeAssistant,
mock_setup_entry: AsyncMock,
mock_smile_config_flow: MagicMock,
) -> None:
"""Test config flow for stretch devices."""
result = await hass.config_entries.flow.async_init(
DOMAIN,
context={CONF_SOURCE: SOURCE_ZEROCONF},
data=TEST_DISCOVERY2,
)
assert result.get("type") is FlowResultType.FORM
assert result.get("errors") == {}
assert result.get("step_id") == "user"
assert "flow_id" in result
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"],
user_input={CONF_PASSWORD: TEST_PASSWORD},
)
await hass.async_block_till_done()
assert result2.get("type") is FlowResultType.CREATE_ENTRY
assert result2.get("title") == "Test Smile Name"
assert result2.get("data") == {
CONF_HOST: TEST_HOST,
CONF_PASSWORD: TEST_PASSWORD,
CONF_PORT: DEFAULT_PORT,
CONF_USERNAME: TEST_USERNAME2,
}
assert len(mock_setup_entry.mock_calls) == 1
assert len(mock_smile_config_flow.connect.mock_calls) == 1
async def test_zercoconf_discovery_update_configuration(
hass: HomeAssistant,
mock_setup_entry: AsyncMock,
mock_smile_config_flow: MagicMock,
) -> None:
"""Test if a discovered device is configured and updated with new host."""
entry = MockConfigEntry(
domain=DOMAIN,
title=CONF_NAME,
data={
CONF_HOST: "0.0.0.0",
CONF_USERNAME: TEST_USERNAME,
CONF_PASSWORD: TEST_PASSWORD,
},
unique_id=TEST_HOSTNAME,
)
entry.add_to_hass(hass)
assert entry.data[CONF_HOST] == "0.0.0.0"
# Test that an invalid discovery doesn't update the entry
mock_smile_config_flow.connect.side_effect = ConnectionFailedError
result = await hass.config_entries.flow.async_init(
DOMAIN,
context={CONF_SOURCE: SOURCE_ZEROCONF},
data=TEST_DISCOVERY,
)
assert result.get("type") is FlowResultType.ABORT
assert result.get("reason") == "already_configured"
assert entry.data[CONF_HOST] == "0.0.0.0"
mock_smile_config_flow.connect.side_effect = None
result = await hass.config_entries.flow.async_init(
DOMAIN,
context={CONF_SOURCE: SOURCE_ZEROCONF},
data=TEST_DISCOVERY,
)
assert result.get("type") is FlowResultType.ABORT
assert result.get("reason") == "already_configured"
assert entry.data[CONF_HOST] == "1.1.1.1"
@pytest.mark.parametrize(
("side_effect", "reason"),
[
(ConnectionFailedError, "cannot_connect"),
(InvalidAuthentication, "invalid_auth"),
(InvalidSetupError, "invalid_setup"),
(InvalidXMLError, "response_error"),
(RuntimeError, "unknown"),
(UnsupportedDeviceError, "unsupported"),
],
)
async def test_flow_errors(
hass: HomeAssistant,
mock_setup_entry: AsyncMock,
mock_smile_config_flow: MagicMock,
side_effect: Exception,
reason: str,
) -> None:
"""Test we handle each exception error."""
result = await hass.config_entries.flow.async_init(
DOMAIN,
context={CONF_SOURCE: SOURCE_USER},
)
assert result.get("type") is FlowResultType.FORM
assert result.get("errors") == {}
assert result.get("step_id") == "user"
assert "flow_id" in result
mock_smile_config_flow.connect.side_effect = side_effect
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"],
user_input={CONF_HOST: TEST_HOST, CONF_PASSWORD: TEST_PASSWORD},
)
assert result2.get("type") is FlowResultType.FORM
assert result2.get("errors") == {"base": reason}
assert result2.get("step_id") == "user"
assert len(mock_setup_entry.mock_calls) == 0
assert len(mock_smile_config_flow.connect.mock_calls) == 1
mock_smile_config_flow.connect.side_effect = None
result3 = await hass.config_entries.flow.async_configure(
result["flow_id"],
user_input={CONF_HOST: TEST_HOST, CONF_PASSWORD: TEST_PASSWORD},
)
assert result3.get("type") is FlowResultType.CREATE_ENTRY
assert result3.get("title") == "Test Smile Name"
assert result3.get("data") == {
CONF_HOST: TEST_HOST,
CONF_PASSWORD: TEST_PASSWORD,
CONF_PORT: DEFAULT_PORT,
CONF_USERNAME: TEST_USERNAME,
}
assert len(mock_setup_entry.mock_calls) == 1
assert len(mock_smile_config_flow.connect.mock_calls) == 2
async def test_user_abort_existing_anna(
hass: HomeAssistant,
mock_setup_entry: AsyncMock,
mock_smile_config_flow: MagicMock,
) -> None:
"""Test the full user configuration flow."""
entry = MockConfigEntry(
domain=DOMAIN,
title=CONF_NAME,
data={
CONF_HOST: TEST_HOST,
CONF_USERNAME: TEST_USERNAME,
CONF_PASSWORD: TEST_PASSWORD,
},
unique_id=TEST_SMILE_HOST,
)
entry.add_to_hass(hass)
result = await hass.config_entries.flow.async_init(
DOMAIN, context={CONF_SOURCE: SOURCE_USER}
)
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"],
user_input={
CONF_HOST: TEST_HOST,
CONF_PASSWORD: TEST_PASSWORD,
},
)
await hass.async_block_till_done()
assert result2.get("type") is FlowResultType.ABORT
assert result2.get("reason") == "already_configured"
async def test_zeroconf_abort_existing_anna(
hass: HomeAssistant,
mock_setup_entry: AsyncMock,
mock_smile_config_flow: MagicMock,
) -> None:
"""Test the full user configuration flow."""
entry = MockConfigEntry(
domain=DOMAIN,
title=CONF_NAME,
data={
CONF_HOST: TEST_HOST,
CONF_USERNAME: TEST_USERNAME,
CONF_PASSWORD: TEST_PASSWORD,
},
unique_id=TEST_HOSTNAME,
)
entry.add_to_hass(hass)
result = await hass.config_entries.flow.async_init(
DOMAIN,
context={CONF_SOURCE: SOURCE_ZEROCONF},
data=TEST_DISCOVERY_ANNA,
)
assert result.get("type") is FlowResultType.ABORT
assert result.get("reason") == "already_configured"
async def test_zeroconf_abort_anna_with_existing_config_entries(
hass: HomeAssistant,
mock_smile_adam: MagicMock,
init_integration: MockConfigEntry,
) -> None:
"""Test we abort Anna discovery with existing config entries."""
result = await hass.config_entries.flow.async_init(
DOMAIN,
context={CONF_SOURCE: SOURCE_ZEROCONF},
data=TEST_DISCOVERY_ANNA,
)
assert result.get("type") is FlowResultType.ABORT
assert result.get("reason") == "anna_with_adam"
async def test_zeroconf_abort_anna_with_adam(hass: HomeAssistant) -> None:
"""Test we abort Anna discovery when an Adam is also discovered."""
result = await hass.config_entries.flow.async_init(
DOMAIN,
context={CONF_SOURCE: SOURCE_ZEROCONF},
data=TEST_DISCOVERY_ANNA,
)
assert result.get("type") is FlowResultType.FORM
assert result.get("step_id") == "user"
flows_in_progress = hass.config_entries.flow._handler_progress_index[DOMAIN]
assert len(flows_in_progress) == 1
assert list(flows_in_progress)[0].product == "smile_thermo"
# Discover Adam, Anna should be aborted and no longer present
result2 = await hass.config_entries.flow.async_init(
DOMAIN,
context={CONF_SOURCE: SOURCE_ZEROCONF},
data=TEST_DISCOVERY_ADAM,
)
assert result2.get("type") is FlowResultType.FORM
assert result2.get("step_id") == "user"
flows_in_progress = hass.config_entries.flow._handler_progress_index[DOMAIN]
assert len(flows_in_progress) == 1
assert list(flows_in_progress)[0].product == "smile_open_therm"
# Discover Anna again, Anna should be aborted directly
result3 = await hass.config_entries.flow.async_init(
DOMAIN,
context={CONF_SOURCE: SOURCE_ZEROCONF},
data=TEST_DISCOVERY_ANNA,
)
assert result3.get("type") is FlowResultType.ABORT
assert result3.get("reason") == "anna_with_adam"
# Adam should still be there
flows_in_progress = hass.config_entries.flow._handler_progress_index[DOMAIN]
assert len(flows_in_progress) == 1
assert list(flows_in_progress)[0].product == "smile_open_therm"
async def _start_reconfigure_flow(
hass: HomeAssistant,
mock_config_entry: MockConfigEntry,
host_ip: str,
) -> ConfigFlowResult:
"""Initialize a reconfigure flow."""
mock_config_entry.add_to_hass(hass)
reconfigure_result = await mock_config_entry.start_reconfigure_flow(hass)
assert reconfigure_result["type"] is FlowResultType.FORM
assert reconfigure_result["step_id"] == "reconfigure"
return await hass.config_entries.flow.async_configure(
reconfigure_result["flow_id"], {CONF_HOST: host_ip}
)
async def test_reconfigure_flow(
hass: HomeAssistant,
mock_smile_adam: AsyncMock,
mock_setup_entry: AsyncMock,
mock_config_entry: MockConfigEntry,
) -> None:
"""Test reconfigure flow."""
result = await _start_reconfigure_flow(hass, mock_config_entry, TEST_HOST)
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "reconfigure_successful"
assert mock_config_entry.data.get(CONF_HOST) == TEST_HOST
async def test_reconfigure_flow_smile_mismatch(
hass: HomeAssistant,
mock_smile_adam: AsyncMock,
mock_setup_entry: AsyncMock,
mock_config_entry: MockConfigEntry,
) -> None:
"""Test reconfigure flow aborts on other Smile ID."""
mock_smile_adam.smile_hostname = TEST_SMILE_HOST
result = await _start_reconfigure_flow(hass, mock_config_entry, TEST_HOST)
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "not_the_same_smile"
@pytest.mark.parametrize(
("side_effect", "reason"),
[
(ConnectionFailedError, "cannot_connect"),
(InvalidAuthentication, "invalid_auth"),
(InvalidSetupError, "invalid_setup"),
(InvalidXMLError, "response_error"),
(RuntimeError, "unknown"),
(UnsupportedDeviceError, "unsupported"),
],
)
async def test_reconfigure_flow_connect_errors(
hass: HomeAssistant,
mock_smile_adam: AsyncMock,
mock_config_entry: MockConfigEntry,
side_effect: Exception,
reason: str,
) -> None:
"""Test we handle each reconfigure exception error and recover."""
mock_smile_adam.connect.side_effect = side_effect
result = await _start_reconfigure_flow(hass, mock_config_entry, TEST_HOST)
assert result.get("type") is FlowResultType.FORM
assert result.get("errors") == {"base": reason}
assert result.get("step_id") == "reconfigure"
mock_smile_adam.connect.side_effect = None
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"], {CONF_HOST: TEST_HOST}
)
assert result2["type"] is FlowResultType.ABORT
assert result2["reason"] == "reconfigure_successful"
assert mock_config_entry.data.get(CONF_HOST) == TEST_HOST

View File

@@ -0,0 +1,26 @@
"""Tests for the diagnostics data provided by the Plugwise integration."""
from unittest.mock import MagicMock
from syrupy import SnapshotAssertion
from homeassistant.core import HomeAssistant
from tests.common import MockConfigEntry
from tests.components.diagnostics import get_diagnostics_for_config_entry
from tests.typing import ClientSessionGenerator
async def test_diagnostics(
hass: HomeAssistant,
hass_client: ClientSessionGenerator,
mock_smile_adam: MagicMock,
init_integration: MockConfigEntry,
snapshot: SnapshotAssertion,
) -> None:
"""Test diagnostics."""
assert (
await get_diagnostics_for_config_entry(hass, hass_client, init_integration)
== snapshot
)

View File

@@ -0,0 +1,324 @@
"""Tests for the Plugwise Climate integration."""
from datetime import timedelta
from unittest.mock import MagicMock, patch
from freezegun.api import FrozenDateTimeFactory
from plugwise.exceptions import (
ConnectionFailedError,
InvalidAuthentication,
InvalidXMLError,
PlugwiseError,
ResponseError,
UnsupportedDeviceError,
)
import pytest
from homeassistant.components.plugwise.const import DOMAIN
from homeassistant.config_entries import ConfigEntryState
from homeassistant.const import Platform
from homeassistant.core import HomeAssistant
from homeassistant.helpers import device_registry as dr, entity_registry as er
from tests.common import MockConfigEntry, async_fire_time_changed
HA_PLUGWISE_SMILE_ASYNC_UPDATE = (
"homeassistant.components.plugwise.coordinator.Smile.async_update"
)
HEATER_ID = "1cbf783bb11e4a7c8a6843dee3a86927" # Opentherm device_id for migration
PLUG_ID = "cd0ddb54ef694e11ac18ed1cbce5dbbd" # VCR device_id for migration
SECONDARY_ID = (
"1cbf783bb11e4a7c8a6843dee3a86927" # Heater_central device_id for migration
)
TOM = {
"01234567890abcdefghijklmnopqrstu": {
"available": True,
"dev_class": "thermostatic_radiator_valve",
"firmware": "2020-11-04T01:00:00+01:00",
"hardware": "1",
"location": "f871b8c4d63549319221e294e4f88074",
"model": "Tom/Floor",
"name": "Tom Badkamer 2",
"binary_sensors": {
"low_battery": False,
},
"sensors": {
"battery": 99,
"setpoint": 18.0,
"temperature": 18.6,
"temperature_difference": 2.3,
"valve_position": 0.0,
},
"temperature_offset": {
"lower_bound": -2.0,
"resolution": 0.1,
"setpoint": 0.1,
"upper_bound": 2.0,
},
"vendor": "Plugwise",
"zigbee_mac_address": "ABCD012345670A01",
},
}
async def test_load_unload_config_entry(
hass: HomeAssistant,
mock_config_entry: MockConfigEntry,
mock_smile_anna: MagicMock,
) -> None:
"""Test the Plugwise configuration entry loading/unloading."""
mock_config_entry.add_to_hass(hass)
await hass.config_entries.async_setup(mock_config_entry.entry_id)
await hass.async_block_till_done()
assert mock_config_entry.state is ConfigEntryState.LOADED
assert len(mock_smile_anna.connect.mock_calls) == 1
await hass.config_entries.async_unload(mock_config_entry.entry_id)
await hass.async_block_till_done()
assert mock_config_entry.state is ConfigEntryState.NOT_LOADED
@pytest.mark.parametrize(
("side_effect", "entry_state"),
[
(ConnectionFailedError, ConfigEntryState.SETUP_RETRY),
(InvalidAuthentication, ConfigEntryState.SETUP_ERROR),
(InvalidXMLError, ConfigEntryState.SETUP_RETRY),
(PlugwiseError, ConfigEntryState.SETUP_RETRY),
(ResponseError, ConfigEntryState.SETUP_RETRY),
(UnsupportedDeviceError, ConfigEntryState.SETUP_ERROR),
],
)
async def test_gateway_config_entry_not_ready(
hass: HomeAssistant,
mock_config_entry: MockConfigEntry,
mock_smile_anna: MagicMock,
side_effect: Exception,
entry_state: ConfigEntryState,
) -> None:
"""Test the Plugwise configuration entry not ready."""
mock_smile_anna.async_update.side_effect = side_effect
mock_config_entry.add_to_hass(hass)
await hass.config_entries.async_setup(mock_config_entry.entry_id)
await hass.async_block_till_done()
assert len(mock_smile_anna.connect.mock_calls) == 1
assert mock_config_entry.state is entry_state
async def test_device_in_dr(
hass: HomeAssistant,
mock_config_entry: MockConfigEntry,
mock_smile_p1: MagicMock,
device_registry: dr.DeviceRegistry,
) -> None:
"""Test Gateway device registry data."""
mock_config_entry.add_to_hass(hass)
await hass.config_entries.async_setup(mock_config_entry.entry_id)
await hass.async_block_till_done()
device_entry = device_registry.async_get_device(
identifiers={(DOMAIN, "a455b61e52394b2db5081ce025a430f3")}
)
assert device_entry.hw_version == "AME Smile 2.0 board"
assert device_entry.manufacturer == "Plugwise"
assert device_entry.model == "Gateway"
assert device_entry.model_id == "smile"
assert device_entry.name == "Smile P1"
assert device_entry.sw_version == "4.4.2"
@pytest.mark.parametrize(
("entitydata", "old_unique_id", "new_unique_id"),
[
(
{
"domain": Platform.SENSOR,
"platform": DOMAIN,
"unique_id": f"{HEATER_ID}-outdoor_temperature",
"suggested_object_id": f"{HEATER_ID}-outdoor_temperature",
"disabled_by": None,
},
f"{HEATER_ID}-outdoor_temperature",
f"{HEATER_ID}-outdoor_air_temperature",
),
],
)
async def test_migrate_unique_id_temperature(
hass: HomeAssistant,
entity_registry: er.EntityRegistry,
mock_config_entry: MockConfigEntry,
mock_smile_anna: MagicMock,
entitydata: dict,
old_unique_id: str,
new_unique_id: str,
) -> None:
"""Test migration of unique_id."""
mock_config_entry.add_to_hass(hass)
entity: entity_registry.RegistryEntry = entity_registry.async_get_or_create(
**entitydata,
config_entry=mock_config_entry,
)
assert entity.unique_id == old_unique_id
assert await hass.config_entries.async_setup(mock_config_entry.entry_id)
await hass.async_block_till_done()
entity_migrated = entity_registry.async_get(entity.entity_id)
assert entity_migrated
assert entity_migrated.unique_id == new_unique_id
@pytest.mark.parametrize(
("entitydata", "old_unique_id", "new_unique_id"),
[
(
{
"domain": Platform.BINARY_SENSOR,
"platform": DOMAIN,
"unique_id": f"{SECONDARY_ID}-slave_boiler_state",
"suggested_object_id": f"{SECONDARY_ID}-slave_boiler_state",
"disabled_by": None,
},
f"{SECONDARY_ID}-slave_boiler_state",
f"{SECONDARY_ID}-secondary_boiler_state",
),
(
{
"domain": Platform.SWITCH,
"platform": DOMAIN,
"unique_id": f"{PLUG_ID}-plug",
"suggested_object_id": f"{PLUG_ID}-plug",
"disabled_by": None,
},
f"{PLUG_ID}-plug",
f"{PLUG_ID}-relay",
),
],
)
async def test_migrate_unique_id_relay(
hass: HomeAssistant,
entity_registry: er.EntityRegistry,
mock_config_entry: MockConfigEntry,
mock_smile_adam: MagicMock,
entitydata: dict,
old_unique_id: str,
new_unique_id: str,
) -> None:
"""Test migration of unique_id."""
mock_config_entry.add_to_hass(hass)
entity: er.RegistryEntry = entity_registry.async_get_or_create(
**entitydata,
config_entry=mock_config_entry,
)
assert entity.unique_id == old_unique_id
assert await hass.config_entries.async_setup(mock_config_entry.entry_id)
await hass.async_block_till_done()
entity_migrated = entity_registry.async_get(entity.entity_id)
assert entity_migrated
assert entity_migrated.unique_id == new_unique_id
async def test_update_device(
hass: HomeAssistant,
mock_config_entry: MockConfigEntry,
mock_smile_adam_2: MagicMock,
device_registry: dr.DeviceRegistry,
entity_registry: er.EntityRegistry,
freezer: FrozenDateTimeFactory,
) -> None:
"""Test a clean-up of the device_registry."""
data = mock_smile_adam_2.async_update.return_value
mock_config_entry.add_to_hass(hass)
await hass.config_entries.async_setup(mock_config_entry.entry_id)
await hass.async_block_till_done()
assert (
len(
er.async_entries_for_config_entry(
entity_registry, mock_config_entry.entry_id
)
)
== 38
)
assert (
len(
dr.async_entries_for_config_entry(
device_registry, mock_config_entry.entry_id
)
)
== 8
)
# Add a 2nd Tom/Floor
data.devices.update(TOM)
data.devices["f871b8c4d63549319221e294e4f88074"]["thermostats"].update(
{
"secondary": [
"01234567890abcdefghijklmnopqrstu",
"1772a4ea304041adb83f357b751341ff",
]
}
)
with patch(HA_PLUGWISE_SMILE_ASYNC_UPDATE, return_value=data):
freezer.tick(timedelta(minutes=1))
async_fire_time_changed(hass)
await hass.async_block_till_done()
assert (
len(
er.async_entries_for_config_entry(
entity_registry, mock_config_entry.entry_id
)
)
== 45
)
assert (
len(
dr.async_entries_for_config_entry(
device_registry, mock_config_entry.entry_id
)
)
== 9
)
item_list: list[str] = []
for device_entry in list(device_registry.devices.values()):
item_list.extend(x[1] for x in device_entry.identifiers)
assert "01234567890abcdefghijklmnopqrstu" in item_list
# Remove the existing Tom/Floor
data.devices["f871b8c4d63549319221e294e4f88074"]["thermostats"].update(
{"secondary": ["01234567890abcdefghijklmnopqrstu"]}
)
data.devices.pop("1772a4ea304041adb83f357b751341ff")
with patch(HA_PLUGWISE_SMILE_ASYNC_UPDATE, return_value=data):
freezer.tick(timedelta(minutes=1))
async_fire_time_changed(hass)
await hass.async_block_till_done()
assert (
len(
er.async_entries_for_config_entry(
entity_registry, mock_config_entry.entry_id
)
)
== 38
)
assert (
len(
dr.async_entries_for_config_entry(
device_registry, mock_config_entry.entry_id
)
)
== 8
)
item_list: list[str] = []
for device_entry in list(device_registry.devices.values()):
item_list.extend(x[1] for x in device_entry.identifiers)
assert "1772a4ea304041adb83f357b751341ff" not in item_list

View File

@@ -0,0 +1,122 @@
"""Tests for the Plugwise Number integration."""
from unittest.mock import MagicMock
import pytest
from homeassistant.components.number import (
ATTR_VALUE,
DOMAIN as NUMBER_DOMAIN,
SERVICE_SET_VALUE,
)
from homeassistant.const import ATTR_ENTITY_ID
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import ServiceValidationError
from tests.common import MockConfigEntry
async def test_anna_number_entities(
hass: HomeAssistant, mock_smile_anna: MagicMock, init_integration: MockConfigEntry
) -> None:
"""Test creation of a number."""
state = hass.states.get("number.opentherm_maximum_boiler_temperature_setpoint")
assert state
assert float(state.state) == 60.0
async def test_anna_max_boiler_temp_change(
hass: HomeAssistant, mock_smile_anna: MagicMock, init_integration: MockConfigEntry
) -> None:
"""Test changing of number entities."""
await hass.services.async_call(
NUMBER_DOMAIN,
SERVICE_SET_VALUE,
{
ATTR_ENTITY_ID: "number.opentherm_maximum_boiler_temperature_setpoint",
ATTR_VALUE: 65,
},
blocking=True,
)
assert mock_smile_anna.set_number.call_count == 1
mock_smile_anna.set_number.assert_called_with(
"1cbf783bb11e4a7c8a6843dee3a86927", "maximum_boiler_temperature", 65.0
)
async def test_adam_number_entities(
hass: HomeAssistant, mock_smile_adam_2: MagicMock, init_integration: MockConfigEntry
) -> None:
"""Test creation of a number."""
state = hass.states.get("number.opentherm_domestic_hot_water_setpoint")
assert state
assert float(state.state) == 60.0
async def test_adam_dhw_setpoint_change(
hass: HomeAssistant, mock_smile_adam_2: MagicMock, init_integration: MockConfigEntry
) -> None:
"""Test changing of number entities."""
await hass.services.async_call(
NUMBER_DOMAIN,
SERVICE_SET_VALUE,
{
ATTR_ENTITY_ID: "number.opentherm_domestic_hot_water_setpoint",
ATTR_VALUE: 55,
},
blocking=True,
)
assert mock_smile_adam_2.set_number.call_count == 1
mock_smile_adam_2.set_number.assert_called_with(
"056ee145a816487eaa69243c3280f8bf", "max_dhw_temperature", 55.0
)
async def test_adam_temperature_offset(
hass: HomeAssistant, mock_smile_adam: MagicMock, init_integration: MockConfigEntry
) -> None:
"""Test creation of the temperature_offset number."""
state = hass.states.get("number.zone_thermostat_jessie_temperature_offset")
assert state
assert float(state.state) == 0.0
assert state.attributes.get("min") == -2.0
assert state.attributes.get("max") == 2.0
assert state.attributes.get("step") == 0.1
async def test_adam_temperature_offset_change(
hass: HomeAssistant, mock_smile_adam: MagicMock, init_integration: MockConfigEntry
) -> None:
"""Test changing of the temperature_offset number."""
await hass.services.async_call(
NUMBER_DOMAIN,
SERVICE_SET_VALUE,
{
ATTR_ENTITY_ID: "number.zone_thermostat_jessie_temperature_offset",
ATTR_VALUE: 1.0,
},
blocking=True,
)
assert mock_smile_adam.set_number.call_count == 1
mock_smile_adam.set_number.assert_called_with(
"6a3bf693d05e48e0b460c815a4fdd09d", "temperature_offset", 1.0
)
async def test_adam_temperature_offset_out_of_bounds_change(
hass: HomeAssistant, mock_smile_adam: MagicMock, init_integration: MockConfigEntry
) -> None:
"""Test changing of the temperature_offset number beyond limits."""
with pytest.raises(ServiceValidationError, match="valid range"):
await hass.services.async_call(
NUMBER_DOMAIN,
SERVICE_SET_VALUE,
{
ATTR_ENTITY_ID: "number.zone_thermostat_jessie_temperature_offset",
ATTR_VALUE: 3.0,
},
blocking=True,
)

View File

@@ -0,0 +1,108 @@
"""Tests for the Plugwise Select integration."""
from unittest.mock import MagicMock
import pytest
from homeassistant.components.select import (
ATTR_OPTION,
DOMAIN as SELECT_DOMAIN,
SERVICE_SELECT_OPTION,
)
from homeassistant.const import ATTR_ENTITY_ID
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import ServiceValidationError
from tests.common import MockConfigEntry
async def test_adam_select_entities(
hass: HomeAssistant, mock_smile_adam: MagicMock, init_integration: MockConfigEntry
) -> None:
"""Test a thermostat Select."""
state = hass.states.get("select.woonkamer_thermostat_schedule")
assert state
assert state.state == "GF7 Woonkamer"
async def test_adam_change_select_entity(
hass: HomeAssistant, mock_smile_adam: MagicMock, init_integration: MockConfigEntry
) -> None:
"""Test changing of select entities."""
await hass.services.async_call(
SELECT_DOMAIN,
SERVICE_SELECT_OPTION,
{
ATTR_ENTITY_ID: "select.woonkamer_thermostat_schedule",
ATTR_OPTION: "Badkamer Schema",
},
blocking=True,
)
assert mock_smile_adam.set_select.call_count == 1
mock_smile_adam.set_select.assert_called_with(
"select_schedule",
"c50f167537524366a5af7aa3942feb1e",
"Badkamer Schema",
"on",
)
async def test_adam_select_regulation_mode(
hass: HomeAssistant, mock_smile_adam_3: MagicMock, init_integration: MockConfigEntry
) -> None:
"""Test a regulation_mode select.
Also tests a change in climate _previous mode.
"""
state = hass.states.get("select.adam_gateway_mode")
assert state
assert state.state == "full"
state = hass.states.get("select.adam_regulation_mode")
assert state
assert state.state == "cooling"
await hass.services.async_call(
SELECT_DOMAIN,
SERVICE_SELECT_OPTION,
{
ATTR_ENTITY_ID: "select.adam_regulation_mode",
ATTR_OPTION: "heating",
},
blocking=True,
)
assert mock_smile_adam_3.set_select.call_count == 1
mock_smile_adam_3.set_select.assert_called_with(
"select_regulation_mode",
"bc93488efab249e5bc54fd7e175a6f91",
"heating",
"on",
)
async def test_legacy_anna_select_entities(
hass: HomeAssistant,
mock_smile_legacy_anna: MagicMock,
init_integration: MockConfigEntry,
) -> None:
"""Test not creating a select-entity for a legacy Anna without a thermostat-schedule."""
assert not hass.states.get("select.anna_thermostat_schedule")
async def test_adam_select_unavailable_regulation_mode(
hass: HomeAssistant, mock_smile_anna: MagicMock, init_integration: MockConfigEntry
) -> None:
"""Test a regulation_mode non-available preset."""
with pytest.raises(ServiceValidationError, match="valid options"):
await hass.services.async_call(
SELECT_DOMAIN,
SERVICE_SELECT_OPTION,
{
ATTR_ENTITY_ID: "select.anna_thermostat_schedule",
ATTR_OPTION: "freezing",
},
blocking=True,
)

View File

@@ -0,0 +1,187 @@
"""Tests for the Plugwise Sensor integration."""
from unittest.mock import MagicMock
import pytest
from homeassistant.components.plugwise.const import DOMAIN
from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_component import async_update_entity
import homeassistant.helpers.entity_registry as er
from tests.common import MockConfigEntry
async def test_adam_climate_sensor_entities(
hass: HomeAssistant, mock_smile_adam: MagicMock, init_integration: MockConfigEntry
) -> None:
"""Test creation of climate related sensor entities."""
state = hass.states.get("sensor.adam_outdoor_temperature")
assert state
assert float(state.state) == 7.81
state = hass.states.get("sensor.cv_pomp_electricity_consumed")
assert state
assert float(state.state) == 35.6
state = hass.states.get("sensor.onoff_water_temperature")
assert state
assert float(state.state) == 70.0
state = hass.states.get("sensor.cv_pomp_electricity_consumed_interval")
assert state
assert float(state.state) == 7.37
await async_update_entity(hass, "sensor.zone_lisa_wk_battery")
state = hass.states.get("sensor.zone_lisa_wk_battery")
assert state
assert int(state.state) == 34
async def test_adam_climate_sensor_entity_2(
hass: HomeAssistant, mock_smile_adam_4: MagicMock, init_integration: MockConfigEntry
) -> None:
"""Test creation of climate related sensor entities."""
state = hass.states.get("sensor.woonkamer_humidity")
assert state
assert float(state.state) == 56.2
async def test_unique_id_migration_humidity(
hass: HomeAssistant,
entity_registry: er.EntityRegistry,
mock_smile_adam_4: MagicMock,
mock_config_entry: MockConfigEntry,
) -> None:
"""Test unique ID migration of -relative_humidity to -humidity."""
mock_config_entry.add_to_hass(hass)
# Entry to migrate
entity_registry.async_get_or_create(
SENSOR_DOMAIN,
DOMAIN,
"f61f1a2535f54f52ad006a3d18e459ca-relative_humidity",
config_entry=mock_config_entry,
suggested_object_id="woonkamer_humidity",
disabled_by=None,
)
# Entry not needing migration
entity_registry.async_get_or_create(
SENSOR_DOMAIN,
DOMAIN,
"f61f1a2535f54f52ad006a3d18e459ca-battery",
config_entry=mock_config_entry,
suggested_object_id="woonkamer_battery",
disabled_by=None,
)
await hass.config_entries.async_setup(mock_config_entry.entry_id)
await hass.async_block_till_done()
assert hass.states.get("sensor.woonkamer_humidity") is not None
assert hass.states.get("sensor.woonkamer_battery") is not None
entity_entry = entity_registry.async_get("sensor.woonkamer_humidity")
assert entity_entry
assert entity_entry.unique_id == "f61f1a2535f54f52ad006a3d18e459ca-humidity"
entity_entry = entity_registry.async_get("sensor.woonkamer_battery")
assert entity_entry
assert entity_entry.unique_id == "f61f1a2535f54f52ad006a3d18e459ca-battery"
async def test_anna_as_smt_climate_sensor_entities(
hass: HomeAssistant, mock_smile_anna: MagicMock, init_integration: MockConfigEntry
) -> None:
"""Test creation of climate related sensor entities."""
state = hass.states.get("sensor.opentherm_outdoor_air_temperature")
assert state
assert float(state.state) == 3.0
state = hass.states.get("sensor.opentherm_water_temperature")
assert state
assert float(state.state) == 29.1
state = hass.states.get("sensor.opentherm_dhw_temperature")
assert state
assert float(state.state) == 46.3
state = hass.states.get("sensor.anna_illuminance")
assert state
assert float(state.state) == 86.0
async def test_p1_dsmr_sensor_entities(
hass: HomeAssistant, mock_smile_p1: MagicMock, init_integration: MockConfigEntry
) -> None:
"""Test creation of power related sensor entities."""
state = hass.states.get("sensor.p1_net_electricity_point")
assert state
assert int(state.state) == 486
state = hass.states.get("sensor.p1_electricity_consumed_off_peak_cumulative")
assert state
assert float(state.state) == 17643.423
state = hass.states.get("sensor.p1_electricity_produced_peak_point")
assert state
assert int(state.state) == 0
state = hass.states.get("sensor.p1_electricity_consumed_peak_cumulative")
assert state
assert float(state.state) == 13966.608
state = hass.states.get("sensor.p1_gas_consumed_cumulative")
assert not state
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_p1_3ph_dsmr_sensor_entities(
hass: HomeAssistant,
entity_registry: er.EntityRegistry,
mock_smile_p1_2: MagicMock,
init_integration: MockConfigEntry,
) -> None:
"""Test creation of power related sensor entities."""
state = hass.states.get("sensor.p1_electricity_phase_one_consumed")
assert state
assert int(state.state) == 1763
state = hass.states.get("sensor.p1_electricity_phase_two_consumed")
assert state
assert int(state.state) == 1703
state = hass.states.get("sensor.p1_electricity_phase_three_consumed")
assert state
assert int(state.state) == 2080
# Default disabled sensor test
state = hass.states.get("sensor.p1_voltage_phase_one")
assert state
assert float(state.state) == 233.2
async def test_p1_3ph_dsmr_sensor_disabled_entities(
hass: HomeAssistant,
entity_registry: er.EntityRegistry,
mock_smile_p1_2: MagicMock,
init_integration: MockConfigEntry,
) -> None:
"""Test disabled power related sensor entities intent."""
state = hass.states.get("sensor.p1_voltage_phase_one")
assert not state
async def test_stretch_sensor_entities(
hass: HomeAssistant, mock_stretch: MagicMock, init_integration: MockConfigEntry
) -> None:
"""Test creation of power related sensor entities."""
state = hass.states.get("sensor.koelkast_92c4a_electricity_consumed")
assert state
assert float(state.state) == 50.5
state = hass.states.get("sensor.droger_52559_electricity_consumed_interval")
assert state
assert float(state.state) == 0.0

View File

@@ -0,0 +1,203 @@
"""Tests for the Plugwise switch integration."""
from unittest.mock import MagicMock
from plugwise.exceptions import PlugwiseException
import pytest
from homeassistant.components.plugwise.const import DOMAIN
from homeassistant.components.switch import DOMAIN as SWITCH_DOMAIN
from homeassistant.const import (
ATTR_ENTITY_ID,
SERVICE_TOGGLE,
SERVICE_TURN_OFF,
SERVICE_TURN_ON,
STATE_OFF,
STATE_ON,
)
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import HomeAssistantError
import homeassistant.helpers.entity_registry as er
from tests.common import MockConfigEntry
async def test_adam_climate_switch_entities(
hass: HomeAssistant, mock_smile_adam: MagicMock, init_integration: MockConfigEntry
) -> None:
"""Test creation of climate related switch entities."""
state = hass.states.get("switch.cv_pomp_relay")
assert state
assert state.state == STATE_ON
state = hass.states.get("switch.fibaro_hc2_relay")
assert state
assert state.state == STATE_ON
async def test_adam_climate_switch_negative_testing(
hass: HomeAssistant, mock_smile_adam: MagicMock, init_integration: MockConfigEntry
) -> None:
"""Test exceptions of climate related switch entities."""
mock_smile_adam.set_switch_state.side_effect = PlugwiseException
with pytest.raises(HomeAssistantError):
await hass.services.async_call(
SWITCH_DOMAIN,
SERVICE_TURN_OFF,
{ATTR_ENTITY_ID: "switch.cv_pomp_relay"},
blocking=True,
)
assert mock_smile_adam.set_switch_state.call_count == 1
mock_smile_adam.set_switch_state.assert_called_with(
"78d1126fc4c743db81b61c20e88342a7", None, "relay", STATE_OFF
)
with pytest.raises(HomeAssistantError):
await hass.services.async_call(
SWITCH_DOMAIN,
SERVICE_TURN_ON,
{ATTR_ENTITY_ID: "switch.fibaro_hc2_relay"},
blocking=True,
)
assert mock_smile_adam.set_switch_state.call_count == 2
mock_smile_adam.set_switch_state.assert_called_with(
"a28f588dc4a049a483fd03a30361ad3a", None, "relay", STATE_ON
)
async def test_adam_climate_switch_changes(
hass: HomeAssistant, mock_smile_adam: MagicMock, init_integration: MockConfigEntry
) -> None:
"""Test changing of climate related switch entities."""
await hass.services.async_call(
SWITCH_DOMAIN,
SERVICE_TURN_OFF,
{ATTR_ENTITY_ID: "switch.cv_pomp_relay"},
blocking=True,
)
assert mock_smile_adam.set_switch_state.call_count == 1
mock_smile_adam.set_switch_state.assert_called_with(
"78d1126fc4c743db81b61c20e88342a7", None, "relay", STATE_OFF
)
await hass.services.async_call(
SWITCH_DOMAIN,
SERVICE_TOGGLE,
{ATTR_ENTITY_ID: "switch.fibaro_hc2_relay"},
blocking=True,
)
assert mock_smile_adam.set_switch_state.call_count == 2
mock_smile_adam.set_switch_state.assert_called_with(
"a28f588dc4a049a483fd03a30361ad3a", None, "relay", STATE_OFF
)
await hass.services.async_call(
SWITCH_DOMAIN,
SERVICE_TURN_ON,
{ATTR_ENTITY_ID: "switch.fibaro_hc2_relay"},
blocking=True,
)
assert mock_smile_adam.set_switch_state.call_count == 3
mock_smile_adam.set_switch_state.assert_called_with(
"a28f588dc4a049a483fd03a30361ad3a", None, "relay", STATE_ON
)
async def test_stretch_switch_entities(
hass: HomeAssistant, mock_stretch: MagicMock, init_integration: MockConfigEntry
) -> None:
"""Test creation of climate related switch entities."""
state = hass.states.get("switch.koelkast_92c4a_relay")
assert state
assert state.state == STATE_ON
state = hass.states.get("switch.droger_52559_relay")
assert state
assert state.state == STATE_ON
async def test_stretch_switch_changes(
hass: HomeAssistant, mock_stretch: MagicMock, init_integration: MockConfigEntry
) -> None:
"""Test changing of power related switch entities."""
await hass.services.async_call(
SWITCH_DOMAIN,
SERVICE_TURN_OFF,
{ATTR_ENTITY_ID: "switch.koelkast_92c4a_relay"},
blocking=True,
)
assert mock_stretch.set_switch_state.call_count == 1
mock_stretch.set_switch_state.assert_called_with(
"e1c884e7dede431dadee09506ec4f859", None, "relay", STATE_OFF
)
await hass.services.async_call(
SWITCH_DOMAIN,
SERVICE_TOGGLE,
{ATTR_ENTITY_ID: "switch.droger_52559_relay"},
blocking=True,
)
assert mock_stretch.set_switch_state.call_count == 2
mock_stretch.set_switch_state.assert_called_with(
"cfe95cf3de1948c0b8955125bf754614", None, "relay", STATE_OFF
)
await hass.services.async_call(
SWITCH_DOMAIN,
SERVICE_TURN_ON,
{ATTR_ENTITY_ID: "switch.droger_52559_relay"},
blocking=True,
)
assert mock_stretch.set_switch_state.call_count == 3
mock_stretch.set_switch_state.assert_called_with(
"cfe95cf3de1948c0b8955125bf754614", None, "relay", STATE_ON
)
async def test_unique_id_migration_plug_relay(
hass: HomeAssistant,
entity_registry: er.EntityRegistry,
mock_smile_adam: MagicMock,
mock_config_entry: MockConfigEntry,
) -> None:
"""Test unique ID migration of -plugs to -relay."""
mock_config_entry.add_to_hass(hass)
# Entry to migrate
entity_registry.async_get_or_create(
SWITCH_DOMAIN,
DOMAIN,
"21f2b542c49845e6bb416884c55778d6-plug",
config_entry=mock_config_entry,
suggested_object_id="playstation_smart_plug",
disabled_by=None,
)
# Entry not needing migration
entity_registry.async_get_or_create(
SWITCH_DOMAIN,
DOMAIN,
"675416a629f343c495449970e2ca37b5-relay",
config_entry=mock_config_entry,
suggested_object_id="ziggo_modem",
disabled_by=None,
)
await hass.config_entries.async_setup(mock_config_entry.entry_id)
await hass.async_block_till_done()
assert hass.states.get("switch.playstation_smart_plug") is not None
assert hass.states.get("switch.ziggo_modem") is not None
entity_entry = entity_registry.async_get("switch.playstation_smart_plug")
assert entity_entry
assert entity_entry.unique_id == "21f2b542c49845e6bb416884c55778d6-relay"
entity_entry = entity_registry.async_get("switch.ziggo_modem")
assert entity_entry
assert entity_entry.unique_id == "675416a629f343c495449970e2ca37b5-relay"