From 8412581be4e61dcfb145865bae3395ece2fae76a Mon Sep 17 00:00:00 2001 From: Bouwe Westerdijk <11290930+bouwew@users.noreply.github.com> Date: Fri, 12 Sep 2025 11:10:49 +0200 Subject: [PATCH] Implement snapshot-testing for Plugwise climate platform (#151070) --- .../plugwise/snapshots/test_climate.ambr | 826 ++++++++++++++++++ tests/components/plugwise/test_climate.py | 346 +++----- 2 files changed, 966 insertions(+), 206 deletions(-) create mode 100644 tests/components/plugwise/snapshots/test_climate.ambr diff --git a/tests/components/plugwise/snapshots/test_climate.ambr b/tests/components/plugwise/snapshots/test_climate.ambr new file mode 100644 index 00000000000..0edb29fabda --- /dev/null +++ b/tests/components/plugwise/snapshots/test_climate.ambr @@ -0,0 +1,826 @@ +# serializer version: 1 +# name: test_adam_2_climate_snapshot[platforms0-False-m_adam_heating][climate.bathroom-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': dict({ + 'hvac_modes': list([ + , + , + , + ]), + 'max_temp': 35.0, + 'min_temp': 0.0, + 'preset_modes': list([ + 'no_frost', + 'asleep', + 'vacation', + 'home', + 'away', + ]), + '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.bathroom', + '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': 'f871b8c4d63549319221e294e4f88074-climate', + 'unit_of_measurement': None, + }) +# --- +# name: test_adam_2_climate_snapshot[platforms0-False-m_adam_heating][climate.bathroom-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'current_temperature': 17.9, + 'friendly_name': 'Bathroom', + 'hvac_action': , + 'hvac_modes': list([ + , + , + , + ]), + 'max_temp': 35.0, + 'min_temp': 0.0, + 'preset_mode': 'home', + 'preset_modes': list([ + 'no_frost', + 'asleep', + 'vacation', + 'home', + 'away', + ]), + 'supported_features': , + 'target_temp_step': 0.1, + 'temperature': 15.0, + }), + 'context': , + 'entity_id': 'climate.bathroom', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'auto', + }) +# --- +# name: test_adam_2_climate_snapshot[platforms0-False-m_adam_heating][climate.living_room-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': dict({ + 'hvac_modes': list([ + , + , + , + ]), + 'max_temp': 35.0, + 'min_temp': 1.0, + 'preset_modes': list([ + 'no_frost', + 'asleep', + 'vacation', + 'home', + 'away', + ]), + '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.living_room', + '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': 'f2bf9048bef64cc5b6d5110154e33c81-climate', + 'unit_of_measurement': None, + }) +# --- +# name: test_adam_2_climate_snapshot[platforms0-False-m_adam_heating][climate.living_room-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'current_temperature': 19.1, + 'friendly_name': 'Living room', + 'hvac_action': , + 'hvac_modes': list([ + , + , + , + ]), + 'max_temp': 35.0, + 'min_temp': 1.0, + 'preset_mode': 'home', + 'preset_modes': list([ + 'no_frost', + 'asleep', + 'vacation', + 'home', + 'away', + ]), + 'supported_features': , + 'target_temp_step': 0.1, + 'temperature': 20.0, + }), + 'context': , + 'entity_id': 'climate.living_room', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'heat', + }) +# --- +# name: test_adam_climate_snapshot[platforms0][climate.badkamer-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': dict({ + 'hvac_modes': list([ + , + , + ]), + 'max_temp': 35.0, + 'min_temp': 0.0, + 'preset_modes': list([ + 'home', + 'asleep', + 'away', + 'vacation', + 'no_frost', + ]), + '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.badkamer', + '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': '08963fec7c53423ca5680aa4cb502c63-climate', + 'unit_of_measurement': None, + }) +# --- +# name: test_adam_climate_snapshot[platforms0][climate.badkamer-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'current_temperature': 18.9, + 'friendly_name': 'Badkamer', + 'hvac_action': , + 'hvac_modes': list([ + , + , + ]), + 'max_temp': 35.0, + 'min_temp': 0.0, + 'preset_mode': 'away', + 'preset_modes': list([ + 'home', + 'asleep', + 'away', + 'vacation', + 'no_frost', + ]), + 'supported_features': , + 'target_temp_step': 0.1, + 'temperature': 14.0, + }), + 'context': , + 'entity_id': 'climate.badkamer', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'auto', + }) +# --- +# name: test_adam_climate_snapshot[platforms0][climate.bios-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': dict({ + 'hvac_modes': list([ + , + , + ]), + 'max_temp': 35.0, + 'min_temp': 0.0, + 'preset_modes': list([ + 'home', + 'asleep', + 'away', + 'vacation', + 'no_frost', + ]), + '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.bios', + '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': '12493538af164a409c6a1c79e38afe1c-climate', + 'unit_of_measurement': None, + }) +# --- +# name: test_adam_climate_snapshot[platforms0][climate.bios-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'current_temperature': 16.5, + 'friendly_name': 'Bios', + 'hvac_action': , + 'hvac_modes': list([ + , + , + ]), + 'max_temp': 35.0, + 'min_temp': 0.0, + 'preset_mode': 'away', + 'preset_modes': list([ + 'home', + 'asleep', + 'away', + 'vacation', + 'no_frost', + ]), + 'supported_features': , + 'target_temp_step': 0.1, + 'temperature': 13.0, + }), + 'context': , + 'entity_id': 'climate.bios', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'heat', + }) +# --- +# name: test_adam_climate_snapshot[platforms0][climate.garage-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': dict({ + 'hvac_modes': list([ + , + ]), + 'max_temp': 35.0, + 'min_temp': 0.0, + 'preset_modes': list([ + 'home', + 'asleep', + 'away', + 'vacation', + 'no_frost', + ]), + '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.garage', + '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': '446ac08dd04d4eff8ac57489757b7314-climate', + 'unit_of_measurement': None, + }) +# --- +# name: test_adam_climate_snapshot[platforms0][climate.garage-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'current_temperature': 15.6, + 'friendly_name': 'Garage', + 'hvac_action': , + 'hvac_modes': list([ + , + ]), + 'max_temp': 35.0, + 'min_temp': 0.0, + 'preset_mode': 'no_frost', + 'preset_modes': list([ + 'home', + 'asleep', + 'away', + 'vacation', + 'no_frost', + ]), + 'supported_features': , + 'target_temp_step': 0.1, + 'temperature': 5.5, + }), + 'context': , + 'entity_id': 'climate.garage', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'heat', + }) +# --- +# name: test_adam_climate_snapshot[platforms0][climate.jessie-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': dict({ + 'hvac_modes': list([ + , + , + ]), + 'max_temp': 35.0, + 'min_temp': 0.0, + 'preset_modes': list([ + 'home', + 'asleep', + 'away', + 'vacation', + 'no_frost', + ]), + '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.jessie', + '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': '82fa13f017d240daa0d0ea1775420f24-climate', + 'unit_of_measurement': None, + }) +# --- +# name: test_adam_climate_snapshot[platforms0][climate.jessie-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'current_temperature': 17.2, + 'friendly_name': 'Jessie', + 'hvac_action': , + 'hvac_modes': list([ + , + , + ]), + 'max_temp': 35.0, + 'min_temp': 0.0, + 'preset_mode': 'asleep', + 'preset_modes': list([ + 'home', + 'asleep', + 'away', + 'vacation', + 'no_frost', + ]), + 'supported_features': , + 'target_temp_step': 0.1, + 'temperature': 15.0, + }), + 'context': , + 'entity_id': 'climate.jessie', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'auto', + }) +# --- +# name: test_adam_climate_snapshot[platforms0][climate.woonkamer-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': dict({ + 'hvac_modes': list([ + , + , + ]), + 'max_temp': 35.0, + 'min_temp': 0.0, + 'preset_modes': list([ + 'home', + 'asleep', + 'away', + 'vacation', + 'no_frost', + ]), + '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.woonkamer', + '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': 'c50f167537524366a5af7aa3942feb1e-climate', + 'unit_of_measurement': None, + }) +# --- +# name: test_adam_climate_snapshot[platforms0][climate.woonkamer-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'current_temperature': 20.9, + 'friendly_name': 'Woonkamer', + 'hvac_action': , + 'hvac_modes': list([ + , + , + ]), + 'max_temp': 35.0, + 'min_temp': 0.0, + 'preset_mode': 'home', + 'preset_modes': list([ + 'home', + 'asleep', + 'away', + 'vacation', + 'no_frost', + ]), + 'supported_features': , + 'target_temp_step': 0.1, + 'temperature': 21.5, + }), + 'context': , + 'entity_id': 'climate.woonkamer', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'auto', + }) +# --- +# name: test_anna_2_climate_snapshot[platforms0-True-m_anna_heatpump_cooling][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_anna_2_climate_snapshot[platforms0-True-m_anna_heatpump_cooling][climate.anna-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'current_temperature': 26.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', + }) +# --- +# name: test_anna_3_climate_snapshot[platforms0-True-m_anna_heatpump_idle][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_anna_3_climate_snapshot[platforms0-True-m_anna_heatpump_idle][climate.anna-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'current_temperature': 23.0, + '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', + }) +# --- +# name: test_anna_climate_snapshot[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_anna_climate_snapshot[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/test_climate.py b/tests/components/plugwise/test_climate.py index b8554f9a5cc..084eaa63d28 100644 --- a/tests/components/plugwise/test_climate.py +++ b/tests/components/plugwise/test_climate.py @@ -6,180 +6,46 @@ from unittest.mock import MagicMock, patch from freezegun.api import FrozenDateTimeFactory from plugwise.exceptions import PlugwiseError import pytest +from syrupy.assertion import SnapshotAssertion 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.const import ATTR_ENTITY_ID, ATTR_TEMPERATURE from homeassistant.core import HomeAssistant from homeassistant.exceptions import HomeAssistantError, ServiceValidationError +from homeassistant.helpers import entity_registry as er -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" ) -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 - - -@pytest.mark.parametrize("chosen_env", ["m_adam_heating"], indirect=True) -@pytest.mark.parametrize("cooling_present", [False], indirect=True) -async def test_adam_2_climate_entity_attributes( +@pytest.mark.parametrize("platforms", [(CLIMATE_DOMAIN,)]) +@pytest.mark.usefixtures("entity_registry_enabled_by_default") +async def test_adam_climate_snapshot( hass: HomeAssistant, - mock_smile_adam_heat_cool: MagicMock, - init_integration: MockConfigEntry, + mock_smile_adam: MagicMock, + snapshot: SnapshotAssertion, + entity_registry: er.EntityRegistry, + setup_platform: 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, - ] - - -@pytest.mark.parametrize("chosen_env", ["m_adam_cooling"], indirect=True) -@pytest.mark.parametrize("cooling_present", [True], indirect=True) -async def test_adam_3_climate_entity_attributes( - hass: HomeAssistant, - mock_smile_adam_heat_cool: 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_heat_cool.async_update.return_value - data["da224107914542988a88561b4452b0f6"]["select_regulation_mode"] = "heating" - data["f2bf9048bef64cc5b6d5110154e33c81"]["control_state"] = HVACAction.HEATING - data["056ee145a816487eaa69243c3280f8bf"]["binary_sensors"]["cooling_state"] = False - data["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_heat_cool.async_update.return_value - data["da224107914542988a88561b4452b0f6"]["select_regulation_mode"] = "cooling" - data["f2bf9048bef64cc5b6d5110154e33c81"]["control_state"] = HVACAction.COOLING - data["056ee145a816487eaa69243c3280f8bf"]["binary_sensors"]["cooling_state"] = True - data["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, - ) + """Test Adam climate snapshot.""" + await snapshot_platform(hass, entity_registry, snapshot, setup_platform.entry_id) async def test_adam_climate_entity_climate_changes( @@ -257,6 +123,95 @@ async def test_adam_climate_entity_climate_changes( ) +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, + ) + + +@pytest.mark.parametrize("chosen_env", ["m_adam_heating"], indirect=True) +@pytest.mark.parametrize("cooling_present", [False], indirect=True) +@pytest.mark.parametrize("platforms", [(CLIMATE_DOMAIN,)]) +@pytest.mark.usefixtures("entity_registry_enabled_by_default") +async def test_adam_2_climate_snapshot( + hass: HomeAssistant, + mock_smile_adam_heat_cool: MagicMock, + snapshot: SnapshotAssertion, + entity_registry: er.EntityRegistry, + setup_platform: MockConfigEntry, +) -> None: + """Test Adam 2 climate snapshot.""" + await snapshot_platform(hass, entity_registry, snapshot, setup_platform.entry_id) + + +@pytest.mark.parametrize("chosen_env", ["m_adam_cooling"], indirect=True) +@pytest.mark.parametrize("cooling_present", [True], indirect=True) +async def test_adam_3_climate_entity_attributes( + hass: HomeAssistant, + mock_smile_adam_heat_cool: 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_heat_cool.async_update.return_value + data["da224107914542988a88561b4452b0f6"]["select_regulation_mode"] = "heating" + data["f2bf9048bef64cc5b6d5110154e33c81"]["control_state"] = HVACAction.HEATING + data["056ee145a816487eaa69243c3280f8bf"]["binary_sensors"]["cooling_state"] = False + data["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_heat_cool.async_update.return_value + data["da224107914542988a88561b4452b0f6"]["select_regulation_mode"] = "cooling" + data["f2bf9048bef64cc5b6d5110154e33c81"]["control_state"] = HVACAction.COOLING + data["056ee145a816487eaa69243c3280f8bf"]["binary_sensors"]["cooling_state"] = True + data["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_off_mode_change( hass: HomeAssistant, mock_smile_adam_jip: MagicMock, @@ -313,68 +268,17 @@ async def test_adam_climate_off_mode_change( @pytest.mark.parametrize("chosen_env", ["anna_heatpump_heating"], indirect=True) @pytest.mark.parametrize("cooling_present", [True], indirect=True) -async def test_anna_climate_entity_attributes( +@pytest.mark.parametrize("platforms", [(CLIMATE_DOMAIN,)]) +@pytest.mark.usefixtures("entity_registry_enabled_by_default") +async def test_anna_climate_snapshot( hass: HomeAssistant, mock_smile_anna: MagicMock, - init_integration: MockConfigEntry, + snapshot: SnapshotAssertion, + entity_registry: er.EntityRegistry, + setup_platform: 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 - - -@pytest.mark.parametrize("chosen_env", ["m_anna_heatpump_cooling"], indirect=True) -@pytest.mark.parametrize("cooling_present", [True], indirect=True) -async def test_anna_2_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.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 - - -@pytest.mark.parametrize("chosen_env", ["m_anna_heatpump_idle"], indirect=True) -@pytest.mark.parametrize("cooling_present", [True], indirect=True) -async def test_anna_3_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.IDLE - assert state.attributes[ATTR_HVAC_MODES] == [ - HVACMode.AUTO, - HVACMode.HEAT_COOL, - ] + """Test Anna climate snapshot.""" + await snapshot_platform(hass, entity_registry, snapshot, setup_platform.entry_id) @pytest.mark.parametrize("chosen_env", ["anna_heatpump_heating"], indirect=True) @@ -446,3 +350,33 @@ async def test_anna_climate_entity_climate_changes( state = hass.states.get("climate.anna") assert state.state == HVACMode.HEAT_COOL assert state.attributes[ATTR_HVAC_MODES] == [HVACMode.HEAT_COOL] + + +@pytest.mark.parametrize("chosen_env", ["m_anna_heatpump_cooling"], 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_anna_2_climate_snapshot( + hass: HomeAssistant, + mock_smile_anna: MagicMock, + snapshot: SnapshotAssertion, + entity_registry: er.EntityRegistry, + setup_platform: MockConfigEntry, +) -> None: + """Test Anna 2 climate snapshot.""" + await snapshot_platform(hass, entity_registry, snapshot, setup_platform.entry_id) + + +@pytest.mark.parametrize("chosen_env", ["m_anna_heatpump_idle"], 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_anna_3_climate_snapshot( + hass: HomeAssistant, + mock_smile_anna: MagicMock, + snapshot: SnapshotAssertion, + entity_registry: er.EntityRegistry, + setup_platform: MockConfigEntry, +) -> None: + """Test Anna 3 climate snapshot.""" + await snapshot_platform(hass, entity_registry, snapshot, setup_platform.entry_id)