From 05ae2c024620bf7ec278fc59acf6a1dfa200a92b Mon Sep 17 00:00:00 2001 From: Tom Scholten Date: Wed, 2 Jul 2025 23:14:47 +0200 Subject: [PATCH 1/4] Rough idea, not working though --- scripts/core-testing.sh | 18 ++++- snap | 2 + tests/components/plugwise/test_setup.py | 93 +++++++++++++++++++++++++ 3 files changed, 111 insertions(+), 2 deletions(-) create mode 100755 snap create mode 100644 tests/components/plugwise/test_setup.py diff --git a/scripts/core-testing.sh b/scripts/core-testing.sh index 073857384..bbd32b59f 100755 --- a/scripts/core-testing.sh +++ b/scripts/core-testing.sh @@ -245,8 +245,22 @@ if [ -z "${GITHUB_ACTIONS}" ] || [ "$1" == "testing" ] ; then if [ ! "${DEBUG}" == "" ] ; then debug_params="-rpP --log-cli-level=DEBUG" fi - # shellcheck disable=SC2086 - pytest ${debug_params} ${subject} tests/components/${REPO_NAME}/${basedir} --snapshot-update --cov=homeassistant/components/${REPO_NAME}/ --cov-report term-missing || exit + # First test if snapshots still valid (silent fail, otherwise will update snapshots) + PYTEST_COMMAND="pytest ${debug_params} ${subject} tests/components/${REPO_NAME}/${basedir} --cov=homeassistant/components/${REPO_NAME}/ --cov-report term-missing" + eval "${PYTEST_COMMAND}" || { + echo "" + echo -e "${CFAIL}Pytest / Snapshot validation failed, re-running to update snapshot ...${CNORM}" + eval "${PYTEST_COMMAND} --snapshot-update" || { + echo "" + echo -e "${CFAIL}Pytest failed, not a snapshot issue ...${CNORM}" || exit 1 + } && { + echo "" + echo -e "${CINFO}Pytest / Snapshot validation passed" + } + } && { + echo "" + echo -e "${CINFO}Pytest / Snapshot validation passed" + } fi # testing if [ -z "${GITHUB_ACTIONS}" ] || [ "$1" == "quality" ] ; then diff --git a/snap b/snap new file mode 100755 index 000000000..b505c82da --- /dev/null +++ b/snap @@ -0,0 +1,2 @@ +#!/bin/bash +(cd ha-core ; cp ../tests/components/plugwise/test_setup.py tests/components/plugwise/ ; source venv/bin/activate; pytest tests/components/plugwise/test_setup.py ; deactivate; cd ..) diff --git a/tests/components/plugwise/test_setup.py b/tests/components/plugwise/test_setup.py new file mode 100644 index 000000000..a4468df0e --- /dev/null +++ b/tests/components/plugwise/test_setup.py @@ -0,0 +1,93 @@ +"""Tests for the Plugwise Climate integration.""" + + +import logging # For potential debugging + +import pytest +from syrupy.assertion import SnapshotAssertion + +from tests.common import MockConfigEntry + +from homeassistant.config_entries import ConfigEntryState +from homeassistant.core import HomeAssistant +from homeassistant.helpers import device_registry as dr +import homeassistant.helpers.entity_registry as er + +_LOGGER = logging.getLogger(__name__) # For logging + + +@pytest.mark.parametrize( + "mock_config_entry, chosen_env, cooling_present", + [ + pytest.param("mock_smile_anna", "anna_heatpump_heating", True, id="Anna Thermostat"), + pytest.param("mock_smile_adam", "adam_multiple_devices_per_zone", True, id="Adam Gateway"), +# pytest.param("mock_stretch", "", id="Stretch Gateway"), + ], + indirect=["mock_config_entry", "chosen_env", "cooling_present"] +) +async def test_plugwise_full_registry_snapshot( + hass: HomeAssistant, + snapshot: SnapshotAssertion, + request: pytest.FixtureRequest, + mock_config_entry: MockConfigEntry, + chosen_env: str, + cooling_present: bool +) -> None: + """Test that all config_entry_mock entities and devices are correctly registered via snapshot.""" + mock_config_entry.add_to_hass(hass) + + await hass.config_entries.async_setup(mock_config_entry.entry_id) + await hass.async_block_till_done() + + _LOGGER.debug("Testing with config entry mock: %s (Environment: %s, Cooling: %s)", + mock_config_entry.title, chosen_env, cooling_present) + + assert mock_config_entry.state is ConfigEntryState.LOADED + + # Determine base name for the snapshot based on the fixture_name + clean_name_part = mock_config_entry.domain # Or mock_config_entry.title.lower().replace(" ", "_") + snapshot_base_name = f"{clean_name_part}_{chosen_env}" + if cooling_present: + snapshot_base_name += "_cooling" + + + entity_registry = er.async_get(hass) + plugwise_entities = {} + for entry in entity_registry.entities.values(): + if entry.config_entry_id == mock_config_entry.entry_id: + plugwise_entities[entry.entity_id] = { + "platform": entry.platform, + "unique_id": entry.unique_id, + "device_id": entry.device_id, + "original_name": entry.original_name, + "original_device_class": entry.original_device_class, + "original_unit_of_measurement": entry.original_unit_of_measurement, + "domain": entry.domain, + "disabled_by": entry.disabled_by, + "hidden_by": entry.hidden_by, + "capabilities": entry.capabilities, + "supported_features": entry.supported_features, + } + + # Sort the dictionary by entity_id for consistent snapshot order + assert dict(sorted(plugwise_entities.items())) == snapshot(name=f"{snapshot_base_name}_entity_registry") + + + device_registry = dr.async_get(hass) + plugwise_devices = {} + for device_entry in device_registry.devices.values(): + if mock_config_entry.entry_id in device_entry.config_entries: + plugwise_devices[device_entry.id] = { + "name": device_entry.name, + "model": device_entry.model, + "manufacturer": device_entry.manufacturer, + "sw_version": device_entry.sw_version, + "hw_version": device_entry.hw_version, + "via_device_id": device_entry.via_device_id, + "identifiers": sorted([list(i) for i in device_entry.identifiers]), # Sort nested lists + "connections": sorted([list(c) for c in device_entry.connections]), # Sort nested lists + "suggested_area": device_entry.suggested_area, + } + + # Sort the dictionary by device ID for consistent snapshot order + assert dict(sorted(plugwise_devices.items())) == snapshot(name=f"{snapshot_base_name}_device_registry") From 22ae0e1ee1f1b0f29aa32a6ee840a8c3ac480521 Mon Sep 17 00:00:00 2001 From: Tom Scholten Date: Mon, 7 Jul 2025 12:42:21 +0200 Subject: [PATCH 2/4] Change to generic approach --- snap | 2 - tests/components/plugwise/conftest.py | 24 ++++- .../components/plugwise/test_binary_sensor.py | 20 +++- tests/components/plugwise/test_setup.py | 93 ------------------- 4 files changed, 42 insertions(+), 97 deletions(-) delete mode 100755 snap delete mode 100644 tests/components/plugwise/test_setup.py diff --git a/snap b/snap deleted file mode 100755 index b505c82da..000000000 --- a/snap +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -(cd ha-core ; cp ../tests/components/plugwise/test_setup.py tests/components/plugwise/ ; source venv/bin/activate; pytest tests/components/plugwise/test_setup.py ; deactivate; cd ..) diff --git a/tests/components/plugwise/conftest.py b/tests/components/plugwise/conftest.py index de96a5560..4c6c2534d 100644 --- a/tests/components/plugwise/conftest.py +++ b/tests/components/plugwise/conftest.py @@ -1,7 +1,7 @@ """Setup mocks for the Plugwise integration tests.""" from __future__ import annotations -from collections.abc import Generator +from collections.abc import AsyncGenerator, Generator import json from typing import Any from unittest.mock import AsyncMock, MagicMock, patch @@ -125,6 +125,28 @@ def mock_smile_config_flow() -> Generator[MagicMock]: yield api +@pytest.fixture +def platforms() -> list[str]: + """Fixture for platforms.""" + return [] + + +@pytest.fixture +async def setup_platform( + hass: HomeAssistant, + mock_config_entry: MockConfigEntry, + platforms, +) -> AsyncGenerator[None]: + """Set up one or all platforms.""" + + mock_config_entry.add_to_hass(hass) + + with patch(f"homeassistant.components.{DOMAIN}.PLATFORMS", platforms): + assert await hass.config_entries.async_setup(mock_config_entry.entry_id) + await hass.async_block_till_done() + yield mock_config_entry + + @pytest.fixture def mock_smile_adam() -> Generator[MagicMock]: """Create a Mock Adam type for testing.""" diff --git a/tests/components/plugwise/test_binary_sensor.py b/tests/components/plugwise/test_binary_sensor.py index 8d9907e94..8c90bef0a 100644 --- a/tests/components/plugwise/test_binary_sensor.py +++ b/tests/components/plugwise/test_binary_sensor.py @@ -6,13 +6,31 @@ import pytest from freezegun.api import FrozenDateTimeFactory +from homeassistant.components.climate import DOMAIN as BINARY_SENSOR_DOMAIN from homeassistant.const import STATE_OFF, STATE_ON from homeassistant.core import HomeAssistant +from homeassistant.helpers import entity_registry as er from homeassistant.helpers.entity_component import async_update_entity +from syrupy.assertion import SnapshotAssertion -from tests.common import MockConfigEntry, async_fire_time_changed +from tests.common import MockConfigEntry, async_fire_time_changed, snapshot_platform +@pytest.mark.parametrize("chosen_env", ["anna_heatpump_heating"], indirect=True) +@pytest.mark.parametrize("cooling_present", [True], indirect=True) +@pytest.mark.parametrize("platforms", [(BINARY_SENSOR_DOMAIN,)]) +@pytest.mark.usefixtures("entity_registry_enabled_by_default") +async def test_binary_sensor_states( + hass: HomeAssistant, + mock_smile_anna: MagicMock, + snapshot: SnapshotAssertion, + entity_registry: er.EntityRegistry, + setup_platform: MockConfigEntry, +) -> None: + """Test binary sensor state.""" + + await snapshot_platform(hass, entity_registry, snapshot, setup_platform.entry_id) + @pytest.mark.parametrize("chosen_env", ["anna_heatpump_heating"], indirect=True) @pytest.mark.parametrize("cooling_present", [True], indirect=True) @pytest.mark.parametrize( diff --git a/tests/components/plugwise/test_setup.py b/tests/components/plugwise/test_setup.py deleted file mode 100644 index a4468df0e..000000000 --- a/tests/components/plugwise/test_setup.py +++ /dev/null @@ -1,93 +0,0 @@ -"""Tests for the Plugwise Climate integration.""" - - -import logging # For potential debugging - -import pytest -from syrupy.assertion import SnapshotAssertion - -from tests.common import MockConfigEntry - -from homeassistant.config_entries import ConfigEntryState -from homeassistant.core import HomeAssistant -from homeassistant.helpers import device_registry as dr -import homeassistant.helpers.entity_registry as er - -_LOGGER = logging.getLogger(__name__) # For logging - - -@pytest.mark.parametrize( - "mock_config_entry, chosen_env, cooling_present", - [ - pytest.param("mock_smile_anna", "anna_heatpump_heating", True, id="Anna Thermostat"), - pytest.param("mock_smile_adam", "adam_multiple_devices_per_zone", True, id="Adam Gateway"), -# pytest.param("mock_stretch", "", id="Stretch Gateway"), - ], - indirect=["mock_config_entry", "chosen_env", "cooling_present"] -) -async def test_plugwise_full_registry_snapshot( - hass: HomeAssistant, - snapshot: SnapshotAssertion, - request: pytest.FixtureRequest, - mock_config_entry: MockConfigEntry, - chosen_env: str, - cooling_present: bool -) -> None: - """Test that all config_entry_mock entities and devices are correctly registered via snapshot.""" - mock_config_entry.add_to_hass(hass) - - await hass.config_entries.async_setup(mock_config_entry.entry_id) - await hass.async_block_till_done() - - _LOGGER.debug("Testing with config entry mock: %s (Environment: %s, Cooling: %s)", - mock_config_entry.title, chosen_env, cooling_present) - - assert mock_config_entry.state is ConfigEntryState.LOADED - - # Determine base name for the snapshot based on the fixture_name - clean_name_part = mock_config_entry.domain # Or mock_config_entry.title.lower().replace(" ", "_") - snapshot_base_name = f"{clean_name_part}_{chosen_env}" - if cooling_present: - snapshot_base_name += "_cooling" - - - entity_registry = er.async_get(hass) - plugwise_entities = {} - for entry in entity_registry.entities.values(): - if entry.config_entry_id == mock_config_entry.entry_id: - plugwise_entities[entry.entity_id] = { - "platform": entry.platform, - "unique_id": entry.unique_id, - "device_id": entry.device_id, - "original_name": entry.original_name, - "original_device_class": entry.original_device_class, - "original_unit_of_measurement": entry.original_unit_of_measurement, - "domain": entry.domain, - "disabled_by": entry.disabled_by, - "hidden_by": entry.hidden_by, - "capabilities": entry.capabilities, - "supported_features": entry.supported_features, - } - - # Sort the dictionary by entity_id for consistent snapshot order - assert dict(sorted(plugwise_entities.items())) == snapshot(name=f"{snapshot_base_name}_entity_registry") - - - device_registry = dr.async_get(hass) - plugwise_devices = {} - for device_entry in device_registry.devices.values(): - if mock_config_entry.entry_id in device_entry.config_entries: - plugwise_devices[device_entry.id] = { - "name": device_entry.name, - "model": device_entry.model, - "manufacturer": device_entry.manufacturer, - "sw_version": device_entry.sw_version, - "hw_version": device_entry.hw_version, - "via_device_id": device_entry.via_device_id, - "identifiers": sorted([list(i) for i in device_entry.identifiers]), # Sort nested lists - "connections": sorted([list(c) for c in device_entry.connections]), # Sort nested lists - "suggested_area": device_entry.suggested_area, - } - - # Sort the dictionary by device ID for consistent snapshot order - assert dict(sorted(plugwise_devices.items())) == snapshot(name=f"{snapshot_base_name}_device_registry") From d73dcb5412818a16934afaa967a514701c382a1c Mon Sep 17 00:00:00 2001 From: Tom Scholten Date: Mon, 7 Jul 2025 12:59:24 +0200 Subject: [PATCH 3/4] Add binary_sensor snapshot --- scripts/core-testing.sh | 7 +- .../snapshots/test_binary_sensor.ambr | 84 +++++++++++++++++++ 2 files changed, 89 insertions(+), 2 deletions(-) create mode 100644 tests/components/plugwise/snapshots/test_binary_sensor.ambr diff --git a/scripts/core-testing.sh b/scripts/core-testing.sh index bbd32b59f..52411208b 100755 --- a/scripts/core-testing.sh +++ b/scripts/core-testing.sh @@ -246,6 +246,7 @@ if [ -z "${GITHUB_ACTIONS}" ] || [ "$1" == "testing" ] ; then debug_params="-rpP --log-cli-level=DEBUG" fi # First test if snapshots still valid (silent fail, otherwise will update snapshots) + SNAPSHOT_UPDATED=0 PYTEST_COMMAND="pytest ${debug_params} ${subject} tests/components/${REPO_NAME}/${basedir} --cov=homeassistant/components/${REPO_NAME}/ --cov-report term-missing" eval "${PYTEST_COMMAND}" || { echo "" @@ -254,8 +255,7 @@ if [ -z "${GITHUB_ACTIONS}" ] || [ "$1" == "testing" ] ; then echo "" echo -e "${CFAIL}Pytest failed, not a snapshot issue ...${CNORM}" || exit 1 } && { - echo "" - echo -e "${CINFO}Pytest / Snapshot validation passed" + SNAPSHOT_UPDATED=1 } } && { echo "" @@ -298,6 +298,9 @@ if [ -z "${GITHUB_ACTIONS}" ]; then echo "" cp -r ./homeassistant/components/${REPO_NAME} ../custom_components/ cp -r ./tests/components/${REPO_NAME} ../tests/components/ + if [ "${SNAPSHOT_UPDATED}" == "1" ]; then + echo -e "${CWARN}Note: updated snapshots ...${CNORM}" + fi echo -e "${CINFO}Removing 'version' from manifest for hassfest-ing, version not allowed in core components${CNORM}" echo "" # shellcheck disable=SC2090 diff --git a/tests/components/plugwise/snapshots/test_binary_sensor.ambr b/tests/components/plugwise/snapshots/test_binary_sensor.ambr new file mode 100644 index 000000000..5c00c1695 --- /dev/null +++ b/tests/components/plugwise/snapshots/test_binary_sensor.ambr @@ -0,0 +1,84 @@ +# serializer version: 1 +# name: test_binary_sensor_states[platforms0-True-anna_heatpump_heating][climate.anna-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': dict({ + 'hvac_modes': list([ + , + , + ]), + 'max_temp': 30.0, + 'min_temp': 4.0, + 'preset_modes': list([ + 'no_frost', + 'home', + 'away', + 'asleep', + 'vacation', + ]), + 'target_temp_step': 0.1, + }), + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'climate', + 'entity_category': None, + 'entity_id': 'climate.anna', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': None, + 'platform': 'plugwise', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': , + 'translation_key': 'plugwise', + 'unique_id': '3cb70739631c4d17a86b8b12e8a5161b-climate', + 'unit_of_measurement': None, + }) +# --- +# name: test_binary_sensor_states[platforms0-True-anna_heatpump_heating][climate.anna-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'current_temperature': 19.3, + 'friendly_name': 'Anna', + 'hvac_action': , + 'hvac_modes': list([ + , + , + ]), + 'max_temp': 30.0, + 'min_temp': 4.0, + 'preset_mode': 'home', + 'preset_modes': list([ + 'no_frost', + 'home', + 'away', + 'asleep', + 'vacation', + ]), + 'supported_features': , + 'target_temp_high': 30.0, + 'target_temp_low': 20.5, + 'target_temp_step': 0.1, + }), + 'context': , + 'entity_id': 'climate.anna', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'auto', + }) +# --- From 0bc6b860b86391ca063e7d7dbed441ff2594f56d Mon Sep 17 00:00:00 2001 From: Tom Scholten Date: Tue, 8 Jul 2025 09:48:26 +0200 Subject: [PATCH 4/4] Smaller approach --- .../snapshots/test_binary_sensor.ambr | 395 +++++++++-- .../plugwise/snapshots/test_climate.ambr | 84 +++ .../plugwise/snapshots/test_sensor.ambr | 666 ++++++++++++++++++ .../components/plugwise/test_binary_sensor.py | 6 +- tests/components/plugwise/test_climate.py | 20 +- tests/components/plugwise/test_sensor.py | 20 +- 6 files changed, 1138 insertions(+), 53 deletions(-) create mode 100644 tests/components/plugwise/snapshots/test_climate.ambr create mode 100644 tests/components/plugwise/snapshots/test_sensor.ambr diff --git a/tests/components/plugwise/snapshots/test_binary_sensor.ambr b/tests/components/plugwise/snapshots/test_binary_sensor.ambr index 5c00c1695..7ff5615a3 100644 --- a/tests/components/plugwise/snapshots/test_binary_sensor.ambr +++ b/tests/components/plugwise/snapshots/test_binary_sensor.ambr @@ -1,33 +1,354 @@ # serializer version: 1 -# name: test_binary_sensor_states[platforms0-True-anna_heatpump_heating][climate.anna-entry] +# name: test_binary_sensor_states[platforms0-True-anna_heatpump_heating][binary_sensor.opentherm_compressor_state-entry] EntityRegistryEntrySnapshot({ 'aliases': set({ }), 'area_id': None, - 'capabilities': dict({ - 'hvac_modes': list([ - , - , - ]), - 'max_temp': 30.0, - 'min_temp': 4.0, - 'preset_modes': list([ - 'no_frost', - 'home', - 'away', - 'asleep', - 'vacation', - ]), - 'target_temp_step': 0.1, + 'capabilities': None, + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'binary_sensor', + 'entity_category': , + 'entity_id': 'binary_sensor.opentherm_compressor_state', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Compressor state', + 'platform': 'plugwise', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': 'compressor_state', + 'unique_id': '1cbf783bb11e4a7c8a6843dee3a86927-compressor_state', + 'unit_of_measurement': None, + }) +# --- +# name: test_binary_sensor_states[platforms0-True-anna_heatpump_heating][binary_sensor.opentherm_compressor_state-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'OpenTherm Compressor state', + }), + 'context': , + 'entity_id': 'binary_sensor.opentherm_compressor_state', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'on', + }) +# --- +# name: test_binary_sensor_states[platforms0-True-anna_heatpump_heating][binary_sensor.opentherm_cooling-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'binary_sensor', + 'entity_category': , + 'entity_id': 'binary_sensor.opentherm_cooling', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Cooling', + 'platform': 'plugwise', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': 'cooling_state', + 'unique_id': '1cbf783bb11e4a7c8a6843dee3a86927-cooling_state', + 'unit_of_measurement': None, + }) +# --- +# name: test_binary_sensor_states[platforms0-True-anna_heatpump_heating][binary_sensor.opentherm_cooling-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'OpenTherm Cooling', + }), + 'context': , + 'entity_id': 'binary_sensor.opentherm_cooling', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'off', + }) +# --- +# name: test_binary_sensor_states[platforms0-True-anna_heatpump_heating][binary_sensor.opentherm_cooling_enabled-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'binary_sensor', + 'entity_category': , + 'entity_id': 'binary_sensor.opentherm_cooling_enabled', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Cooling enabled', + 'platform': 'plugwise', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': 'cooling_enabled', + 'unique_id': '1cbf783bb11e4a7c8a6843dee3a86927-cooling_enabled', + 'unit_of_measurement': None, + }) +# --- +# name: test_binary_sensor_states[platforms0-True-anna_heatpump_heating][binary_sensor.opentherm_cooling_enabled-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'OpenTherm Cooling enabled', + }), + 'context': , + 'entity_id': 'binary_sensor.opentherm_cooling_enabled', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'off', + }) +# --- +# name: test_binary_sensor_states[platforms0-True-anna_heatpump_heating][binary_sensor.opentherm_dhw_state-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'binary_sensor', + 'entity_category': , + 'entity_id': 'binary_sensor.opentherm_dhw_state', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'DHW state', + 'platform': 'plugwise', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': 'dhw_state', + 'unique_id': '1cbf783bb11e4a7c8a6843dee3a86927-dhw_state', + 'unit_of_measurement': None, + }) +# --- +# name: test_binary_sensor_states[platforms0-True-anna_heatpump_heating][binary_sensor.opentherm_dhw_state-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'OpenTherm DHW state', + }), + 'context': , + 'entity_id': 'binary_sensor.opentherm_dhw_state', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'off', + }) +# --- +# name: test_binary_sensor_states[platforms0-True-anna_heatpump_heating][binary_sensor.opentherm_flame_state-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'binary_sensor', + 'entity_category': , + 'entity_id': 'binary_sensor.opentherm_flame_state', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Flame state', + 'platform': 'plugwise', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': 'flame_state', + 'unique_id': '1cbf783bb11e4a7c8a6843dee3a86927-flame_state', + 'unit_of_measurement': None, + }) +# --- +# name: test_binary_sensor_states[platforms0-True-anna_heatpump_heating][binary_sensor.opentherm_flame_state-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'OpenTherm Flame state', + }), + 'context': , + 'entity_id': 'binary_sensor.opentherm_flame_state', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'off', + }) +# --- +# name: test_binary_sensor_states[platforms0-True-anna_heatpump_heating][binary_sensor.opentherm_heating-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'binary_sensor', + 'entity_category': , + 'entity_id': 'binary_sensor.opentherm_heating', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Heating', + 'platform': 'plugwise', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': 'heating_state', + 'unique_id': '1cbf783bb11e4a7c8a6843dee3a86927-heating_state', + 'unit_of_measurement': None, + }) +# --- +# name: test_binary_sensor_states[platforms0-True-anna_heatpump_heating][binary_sensor.opentherm_heating-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'OpenTherm Heating', }), + 'context': , + 'entity_id': 'binary_sensor.opentherm_heating', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'on', + }) +# --- +# name: test_binary_sensor_states[platforms0-True-anna_heatpump_heating][binary_sensor.opentherm_secondary_boiler_state-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'binary_sensor', + 'entity_category': , + 'entity_id': 'binary_sensor.opentherm_secondary_boiler_state', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Secondary boiler state', + 'platform': 'plugwise', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': 'secondary_boiler_state', + 'unique_id': '1cbf783bb11e4a7c8a6843dee3a86927-secondary_boiler_state', + 'unit_of_measurement': None, + }) +# --- +# name: test_binary_sensor_states[platforms0-True-anna_heatpump_heating][binary_sensor.opentherm_secondary_boiler_state-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'OpenTherm Secondary boiler state', + }), + 'context': , + 'entity_id': 'binary_sensor.opentherm_secondary_boiler_state', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'off', + }) +# --- +# name: test_binary_sensor_states[platforms0-True-anna_heatpump_heating][binary_sensor.smile_anna_plugwise_notification-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, 'config_entry_id': , 'config_subentry_id': , 'device_class': None, 'device_id': , 'disabled_by': None, - 'domain': 'climate', - 'entity_category': None, - 'entity_id': 'climate.anna', + 'domain': 'binary_sensor', + 'entity_category': , + 'entity_id': 'binary_sensor.smile_anna_plugwise_notification', 'has_entity_name': True, 'hidden_by': None, 'icon': None, @@ -39,46 +360,26 @@ }), 'original_device_class': None, 'original_icon': None, - 'original_name': None, + 'original_name': 'Plugwise notification', 'platform': 'plugwise', 'previous_unique_id': None, 'suggested_object_id': None, - 'supported_features': , - 'translation_key': 'plugwise', - 'unique_id': '3cb70739631c4d17a86b8b12e8a5161b-climate', + 'supported_features': 0, + 'translation_key': 'plugwise_notification', + 'unique_id': '015ae9ea3f964e668e490fa39da3870b-plugwise_notification', 'unit_of_measurement': None, }) # --- -# name: test_binary_sensor_states[platforms0-True-anna_heatpump_heating][climate.anna-state] +# name: test_binary_sensor_states[platforms0-True-anna_heatpump_heating][binary_sensor.smile_anna_plugwise_notification-state] StateSnapshot({ 'attributes': ReadOnlyDict({ - 'current_temperature': 19.3, - 'friendly_name': 'Anna', - 'hvac_action': , - 'hvac_modes': list([ - , - , - ]), - 'max_temp': 30.0, - 'min_temp': 4.0, - 'preset_mode': 'home', - 'preset_modes': list([ - 'no_frost', - 'home', - 'away', - 'asleep', - 'vacation', - ]), - 'supported_features': , - 'target_temp_high': 30.0, - 'target_temp_low': 20.5, - 'target_temp_step': 0.1, + 'friendly_name': 'Smile Anna Plugwise notification', }), 'context': , - 'entity_id': 'climate.anna', + 'entity_id': 'binary_sensor.smile_anna_plugwise_notification', 'last_changed': , 'last_reported': , 'last_updated': , - 'state': 'auto', + 'state': 'off', }) # --- diff --git a/tests/components/plugwise/snapshots/test_climate.ambr b/tests/components/plugwise/snapshots/test_climate.ambr new file mode 100644 index 000000000..5c00c1695 --- /dev/null +++ b/tests/components/plugwise/snapshots/test_climate.ambr @@ -0,0 +1,84 @@ +# serializer version: 1 +# name: test_binary_sensor_states[platforms0-True-anna_heatpump_heating][climate.anna-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': dict({ + 'hvac_modes': list([ + , + , + ]), + 'max_temp': 30.0, + 'min_temp': 4.0, + 'preset_modes': list([ + 'no_frost', + 'home', + 'away', + 'asleep', + 'vacation', + ]), + 'target_temp_step': 0.1, + }), + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'climate', + 'entity_category': None, + 'entity_id': 'climate.anna', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': None, + 'platform': 'plugwise', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': , + 'translation_key': 'plugwise', + 'unique_id': '3cb70739631c4d17a86b8b12e8a5161b-climate', + 'unit_of_measurement': None, + }) +# --- +# name: test_binary_sensor_states[platforms0-True-anna_heatpump_heating][climate.anna-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'current_temperature': 19.3, + 'friendly_name': 'Anna', + 'hvac_action': , + 'hvac_modes': list([ + , + , + ]), + 'max_temp': 30.0, + 'min_temp': 4.0, + 'preset_mode': 'home', + 'preset_modes': list([ + 'no_frost', + 'home', + 'away', + 'asleep', + 'vacation', + ]), + 'supported_features': , + 'target_temp_high': 30.0, + 'target_temp_low': 20.5, + 'target_temp_step': 0.1, + }), + 'context': , + 'entity_id': 'climate.anna', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'auto', + }) +# --- diff --git a/tests/components/plugwise/snapshots/test_sensor.ambr b/tests/components/plugwise/snapshots/test_sensor.ambr new file mode 100644 index 000000000..579e3038d --- /dev/null +++ b/tests/components/plugwise/snapshots/test_sensor.ambr @@ -0,0 +1,666 @@ +# serializer version: 1 +# name: test_binary_sensor_states[platforms0-True-anna_heatpump_heating][sensor.anna_cooling_setpoint-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': dict({ + 'state_class': , + }), + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': , + 'entity_id': 'sensor.anna_cooling_setpoint', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + 'sensor': dict({ + 'suggested_display_precision': 1, + }), + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Cooling setpoint', + 'platform': 'plugwise', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': 'cooling_setpoint', + 'unique_id': '3cb70739631c4d17a86b8b12e8a5161b-setpoint_high', + 'unit_of_measurement': , + }) +# --- +# name: test_binary_sensor_states[platforms0-True-anna_heatpump_heating][sensor.anna_cooling_setpoint-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'temperature', + 'friendly_name': 'Anna Cooling setpoint', + 'state_class': , + 'unit_of_measurement': , + }), + 'context': , + 'entity_id': 'sensor.anna_cooling_setpoint', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '30.0', + }) +# --- +# name: test_binary_sensor_states[platforms0-True-anna_heatpump_heating][sensor.anna_heating_setpoint-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': dict({ + 'state_class': , + }), + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': , + 'entity_id': 'sensor.anna_heating_setpoint', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + 'sensor': dict({ + 'suggested_display_precision': 1, + }), + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Heating setpoint', + 'platform': 'plugwise', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': 'heating_setpoint', + 'unique_id': '3cb70739631c4d17a86b8b12e8a5161b-setpoint_low', + 'unit_of_measurement': , + }) +# --- +# name: test_binary_sensor_states[platforms0-True-anna_heatpump_heating][sensor.anna_heating_setpoint-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'temperature', + 'friendly_name': 'Anna Heating setpoint', + 'state_class': , + 'unit_of_measurement': , + }), + 'context': , + 'entity_id': 'sensor.anna_heating_setpoint', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '20.5', + }) +# --- +# name: test_binary_sensor_states[platforms0-True-anna_heatpump_heating][sensor.anna_illuminance-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': dict({ + 'state_class': , + }), + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': , + 'entity_id': 'sensor.anna_illuminance', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Illuminance', + 'platform': 'plugwise', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': None, + 'unique_id': '3cb70739631c4d17a86b8b12e8a5161b-illuminance', + 'unit_of_measurement': 'lx', + }) +# --- +# name: test_binary_sensor_states[platforms0-True-anna_heatpump_heating][sensor.anna_illuminance-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'illuminance', + 'friendly_name': 'Anna Illuminance', + 'state_class': , + 'unit_of_measurement': 'lx', + }), + 'context': , + 'entity_id': 'sensor.anna_illuminance', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '86.0', + }) +# --- +# name: test_binary_sensor_states[platforms0-True-anna_heatpump_heating][sensor.anna_temperature-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': dict({ + 'state_class': , + }), + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': , + 'entity_id': 'sensor.anna_temperature', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + 'sensor': dict({ + 'suggested_display_precision': 1, + }), + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Temperature', + 'platform': 'plugwise', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': None, + 'unique_id': '3cb70739631c4d17a86b8b12e8a5161b-temperature', + 'unit_of_measurement': , + }) +# --- +# name: test_binary_sensor_states[platforms0-True-anna_heatpump_heating][sensor.anna_temperature-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'temperature', + 'friendly_name': 'Anna Temperature', + 'state_class': , + 'unit_of_measurement': , + }), + 'context': , + 'entity_id': 'sensor.anna_temperature', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '19.3', + }) +# --- +# name: test_binary_sensor_states[platforms0-True-anna_heatpump_heating][sensor.opentherm_dhw_temperature-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': dict({ + 'state_class': , + }), + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': , + 'entity_id': 'sensor.opentherm_dhw_temperature', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + 'sensor': dict({ + 'suggested_display_precision': 1, + }), + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'DHW temperature', + 'platform': 'plugwise', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': 'dhw_temperature', + 'unique_id': '1cbf783bb11e4a7c8a6843dee3a86927-dhw_temperature', + 'unit_of_measurement': , + }) +# --- +# name: test_binary_sensor_states[platforms0-True-anna_heatpump_heating][sensor.opentherm_dhw_temperature-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'temperature', + 'friendly_name': 'OpenTherm DHW temperature', + 'state_class': , + 'unit_of_measurement': , + }), + 'context': , + 'entity_id': 'sensor.opentherm_dhw_temperature', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '46.3', + }) +# --- +# name: test_binary_sensor_states[platforms0-True-anna_heatpump_heating][sensor.opentherm_intended_boiler_temperature-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': dict({ + 'state_class': , + }), + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': , + 'entity_id': 'sensor.opentherm_intended_boiler_temperature', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + 'sensor': dict({ + 'suggested_display_precision': 1, + }), + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Intended boiler temperature', + 'platform': 'plugwise', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': 'intended_boiler_temperature', + 'unique_id': '1cbf783bb11e4a7c8a6843dee3a86927-intended_boiler_temperature', + 'unit_of_measurement': , + }) +# --- +# name: test_binary_sensor_states[platforms0-True-anna_heatpump_heating][sensor.opentherm_intended_boiler_temperature-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'temperature', + 'friendly_name': 'OpenTherm Intended boiler temperature', + 'state_class': , + 'unit_of_measurement': , + }), + 'context': , + 'entity_id': 'sensor.opentherm_intended_boiler_temperature', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '35.0', + }) +# --- +# name: test_binary_sensor_states[platforms0-True-anna_heatpump_heating][sensor.opentherm_modulation_level-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': dict({ + 'state_class': , + }), + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': , + 'entity_id': 'sensor.opentherm_modulation_level', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Modulation level', + 'platform': 'plugwise', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': 'modulation_level', + 'unique_id': '1cbf783bb11e4a7c8a6843dee3a86927-modulation_level', + 'unit_of_measurement': '%', + }) +# --- +# name: test_binary_sensor_states[platforms0-True-anna_heatpump_heating][sensor.opentherm_modulation_level-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'OpenTherm Modulation level', + 'state_class': , + 'unit_of_measurement': '%', + }), + 'context': , + 'entity_id': 'sensor.opentherm_modulation_level', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '52', + }) +# --- +# name: test_binary_sensor_states[platforms0-True-anna_heatpump_heating][sensor.opentherm_outdoor_air_temperature-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': dict({ + 'state_class': , + }), + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': , + 'entity_id': 'sensor.opentherm_outdoor_air_temperature', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + 'sensor': dict({ + 'suggested_display_precision': 1, + }), + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Outdoor air temperature', + 'platform': 'plugwise', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': 'outdoor_air_temperature', + 'unique_id': '1cbf783bb11e4a7c8a6843dee3a86927-outdoor_air_temperature', + 'unit_of_measurement': , + }) +# --- +# name: test_binary_sensor_states[platforms0-True-anna_heatpump_heating][sensor.opentherm_outdoor_air_temperature-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'temperature', + 'friendly_name': 'OpenTherm Outdoor air temperature', + 'state_class': , + 'unit_of_measurement': , + }), + 'context': , + 'entity_id': 'sensor.opentherm_outdoor_air_temperature', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '3.0', + }) +# --- +# name: test_binary_sensor_states[platforms0-True-anna_heatpump_heating][sensor.opentherm_return_temperature-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': dict({ + 'state_class': , + }), + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': , + 'entity_id': 'sensor.opentherm_return_temperature', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + 'sensor': dict({ + 'suggested_display_precision': 1, + }), + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Return temperature', + 'platform': 'plugwise', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': 'return_temperature', + 'unique_id': '1cbf783bb11e4a7c8a6843dee3a86927-return_temperature', + 'unit_of_measurement': , + }) +# --- +# name: test_binary_sensor_states[platforms0-True-anna_heatpump_heating][sensor.opentherm_return_temperature-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'temperature', + 'friendly_name': 'OpenTherm Return temperature', + 'state_class': , + 'unit_of_measurement': , + }), + 'context': , + 'entity_id': 'sensor.opentherm_return_temperature', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '25.1', + }) +# --- +# name: test_binary_sensor_states[platforms0-True-anna_heatpump_heating][sensor.opentherm_water_pressure-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': dict({ + 'state_class': , + }), + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': , + 'entity_id': 'sensor.opentherm_water_pressure', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + 'sensor': dict({ + 'suggested_display_precision': 2, + }), + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Water pressure', + 'platform': 'plugwise', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': 'water_pressure', + 'unique_id': '1cbf783bb11e4a7c8a6843dee3a86927-water_pressure', + 'unit_of_measurement': , + }) +# --- +# name: test_binary_sensor_states[platforms0-True-anna_heatpump_heating][sensor.opentherm_water_pressure-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'pressure', + 'friendly_name': 'OpenTherm Water pressure', + 'state_class': , + 'unit_of_measurement': , + }), + 'context': , + 'entity_id': 'sensor.opentherm_water_pressure', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '1.57', + }) +# --- +# name: test_binary_sensor_states[platforms0-True-anna_heatpump_heating][sensor.opentherm_water_temperature-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': dict({ + 'state_class': , + }), + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': , + 'entity_id': 'sensor.opentherm_water_temperature', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + 'sensor': dict({ + 'suggested_display_precision': 1, + }), + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Water temperature', + 'platform': 'plugwise', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': 'water_temperature', + 'unique_id': '1cbf783bb11e4a7c8a6843dee3a86927-water_temperature', + 'unit_of_measurement': , + }) +# --- +# name: test_binary_sensor_states[platforms0-True-anna_heatpump_heating][sensor.opentherm_water_temperature-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'temperature', + 'friendly_name': 'OpenTherm Water temperature', + 'state_class': , + 'unit_of_measurement': , + }), + 'context': , + 'entity_id': 'sensor.opentherm_water_temperature', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '29.1', + }) +# --- +# name: test_binary_sensor_states[platforms0-True-anna_heatpump_heating][sensor.smile_anna_outdoor_temperature-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': dict({ + 'state_class': , + }), + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': None, + 'entity_id': 'sensor.smile_anna_outdoor_temperature', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + 'sensor': dict({ + 'suggested_display_precision': 1, + }), + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Outdoor temperature', + 'platform': 'plugwise', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': 'outdoor_temperature', + 'unique_id': '015ae9ea3f964e668e490fa39da3870b-outdoor_temperature', + 'unit_of_measurement': , + }) +# --- +# name: test_binary_sensor_states[platforms0-True-anna_heatpump_heating][sensor.smile_anna_outdoor_temperature-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'temperature', + 'friendly_name': 'Smile Anna Outdoor temperature', + 'state_class': , + 'unit_of_measurement': , + }), + 'context': , + 'entity_id': 'sensor.smile_anna_outdoor_temperature', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '20.2', + }) +# --- diff --git a/tests/components/plugwise/test_binary_sensor.py b/tests/components/plugwise/test_binary_sensor.py index 8c90bef0a..116114ba3 100644 --- a/tests/components/plugwise/test_binary_sensor.py +++ b/tests/components/plugwise/test_binary_sensor.py @@ -6,7 +6,7 @@ import pytest from freezegun.api import FrozenDateTimeFactory -from homeassistant.components.climate import DOMAIN as BINARY_SENSOR_DOMAIN +from homeassistant.components.binary_sensor import DOMAIN as BINARY_SENSOR_DOMAIN from homeassistant.const import STATE_OFF, STATE_ON from homeassistant.core import HomeAssistant from homeassistant.helpers import entity_registry as er @@ -27,10 +27,10 @@ async def test_binary_sensor_states( entity_registry: er.EntityRegistry, setup_platform: MockConfigEntry, ) -> None: - """Test binary sensor state.""" - + """Test binary sensor snapshot.""" await snapshot_platform(hass, entity_registry, snapshot, setup_platform.entry_id) + @pytest.mark.parametrize("chosen_env", ["anna_heatpump_heating"], indirect=True) @pytest.mark.parametrize("cooling_present", [True], indirect=True) @pytest.mark.parametrize( diff --git a/tests/components/plugwise/test_climate.py b/tests/components/plugwise/test_climate.py index edafecd85..5e2483d7d 100644 --- a/tests/components/plugwise/test_climate.py +++ b/tests/components/plugwise/test_climate.py @@ -17,8 +17,10 @@ ) from homeassistant.core import HomeAssistant from homeassistant.exceptions import HomeAssistantError, ServiceValidationError +from homeassistant.helpers import entity_registry as er +from syrupy.assertion import SnapshotAssertion -from tests.common import MockConfigEntry, async_fire_time_changed +from tests.common import MockConfigEntry, async_fire_time_changed, snapshot_platform HA_PLUGWISE_SMILE_ASYNC_UPDATE = ( "homeassistant.components.plugwise.coordinator.Smile.async_update" @@ -27,6 +29,21 @@ TEST_PASSWORD = "test_password" +@pytest.mark.parametrize("chosen_env", ["anna_heatpump_heating"], indirect=True) +@pytest.mark.parametrize("cooling_present", [True], indirect=True) +@pytest.mark.parametrize("platforms", [(CLIMATE_DOMAIN,)]) +@pytest.mark.usefixtures("entity_registry_enabled_by_default") +async def test_binary_sensor_states( + hass: HomeAssistant, + mock_smile_anna: MagicMock, + snapshot: SnapshotAssertion, + entity_registry: er.EntityRegistry, + setup_platform: MockConfigEntry, +) -> None: + """Test climate snapshot.""" + await snapshot_platform(hass, entity_registry, snapshot, setup_platform.entry_id) + + async def test_adam_climate_entity_attributes( hass: HomeAssistant, mock_smile_adam: MagicMock, init_integration: MockConfigEntry ) -> None: @@ -441,6 +458,7 @@ async def test_anna_climate_entity_climate_changes( freezer.tick(timedelta(minutes=1)) async_fire_time_changed(hass) await hass.async_block_till_done() + await hass.async_block_till_done() state = hass.states.get("climate.anna") assert state.state == HVACMode.HEAT diff --git a/tests/components/plugwise/test_sensor.py b/tests/components/plugwise/test_sensor.py index 4d655e923..70d93dee8 100644 --- a/tests/components/plugwise/test_sensor.py +++ b/tests/components/plugwise/test_sensor.py @@ -7,10 +7,26 @@ from homeassistant.components.plugwise.const import DOMAIN from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN from homeassistant.core import HomeAssistant +from homeassistant.helpers import entity_registry as er from homeassistant.helpers.entity_component import async_update_entity -import homeassistant.helpers.entity_registry as er +from syrupy.assertion import SnapshotAssertion -from tests.common import MockConfigEntry +from tests.common import MockConfigEntry, snapshot_platform + + +@pytest.mark.parametrize("chosen_env", ["anna_heatpump_heating"], indirect=True) +@pytest.mark.parametrize("cooling_present", [True], indirect=True) +@pytest.mark.parametrize("platforms", [(SENSOR_DOMAIN,)]) +@pytest.mark.usefixtures("entity_registry_enabled_by_default") +async def test_binary_sensor_states( + hass: HomeAssistant, + mock_smile_anna: MagicMock, + snapshot: SnapshotAssertion, + entity_registry: er.EntityRegistry, + setup_platform: MockConfigEntry, +) -> None: + """Test sensor snapshot.""" + await snapshot_platform(hass, entity_registry, snapshot, setup_platform.entry_id) async def test_adam_climate_sensor_entities(