diff --git a/CHANGELOG.md b/CHANGELOG.md index 45b4e38d2..8cb9fa92a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ Versions from 0.40 and up ## Ongoing +- New feature: implement setting Adam zone profile via PR [#958](https://github.com/plugwise/plugwise-beta/pull/958) - Implement translation for added homeassistantError raise message via PR [#948](https://github.com/plugwise/plugwise-beta/pull/948) - Line up strings with Core Plugwise strings via PR [#954](https://github.com/plugwise/plugwise-beta/pull/954) diff --git a/custom_components/plugwise/const.py b/custom_components/plugwise/const.py index 26931ba98..ab4fac9c6 100644 --- a/custom_components/plugwise/const.py +++ b/custom_components/plugwise/const.py @@ -129,16 +129,15 @@ # Select constants AVAILABLE_SCHEDULES: Final = "available_schedules" -DHW_MODE: Final = "dhw_mode" DHW_MODES: Final = "dhw_modes" -GATEWAY_MODE: Final = "gateway_mode" GATEWAY_MODES: Final = "gateway_modes" -REGULATION_MODE: Final = "regulation_mode" REGULATION_MODES: Final = "regulation_modes" +ZONE_PROFILES: Final = "zone_profiles" SELECT_DHW_MODE: Final = "select_dhw_mode" SELECT_GATEWAY_MODE: Final = "select_gateway_mode" SELECT_REGULATION_MODE: Final = "select_regulation_mode" SELECT_SCHEDULE: Final = "select_schedule" +SELECT_ZONE_PROFILE: Final = "select_zone_profile" # Switch constants DHW_CM_SWITCH: Final = "dhw_cm_switch" @@ -198,10 +197,12 @@ "select_gateway_mode", "select_regulation_mode", "select_schedule", + "select_zone_profile" ] type SelectOptionsType = Literal[ + "available_schedules", "dhw_modes", "gateway_modes", "regulation_modes", - "available_schedules", + "zone_profiles", ] diff --git a/custom_components/plugwise/manifest.json b/custom_components/plugwise/manifest.json index d5f4d9df8..80819e5ea 100644 --- a/custom_components/plugwise/manifest.json +++ b/custom_components/plugwise/manifest.json @@ -7,7 +7,7 @@ "integration_type": "hub", "iot_class": "local_polling", "loggers": ["plugwise"], - "requirements": ["plugwise==1.9.0"], + "requirements": ["plugwise==1.10.0"], "version": "0.60.0", "zeroconf": ["_plugwise._tcp.local."] } diff --git a/custom_components/plugwise/select.py b/custom_components/plugwise/select.py index 5a195ee5e..c766d6903 100644 --- a/custom_components/plugwise/select.py +++ b/custom_components/plugwise/select.py @@ -11,18 +11,17 @@ from .const import ( AVAILABLE_SCHEDULES, - DHW_MODE, DHW_MODES, - GATEWAY_MODE, GATEWAY_MODES, LOCATION, LOGGER, - REGULATION_MODE, REGULATION_MODES, SELECT_DHW_MODE, SELECT_GATEWAY_MODE, SELECT_REGULATION_MODE, SELECT_SCHEDULE, + SELECT_ZONE_PROFILE, + ZONE_PROFILES, SelectOptionsType, SelectType, ) @@ -43,7 +42,7 @@ class PlugwiseSelectEntityDescription(SelectEntityDescription): options_key: SelectOptionsType -# Upstream + is there a reason we didn't rename this one prefixed? +# Upstream SELECT_TYPES = ( PlugwiseSelectEntityDescription( key=SELECT_SCHEDULE, @@ -52,22 +51,28 @@ class PlugwiseSelectEntityDescription(SelectEntityDescription): ), PlugwiseSelectEntityDescription( key=SELECT_REGULATION_MODE, - translation_key=REGULATION_MODE, + translation_key=SELECT_REGULATION_MODE, entity_category=EntityCategory.CONFIG, options_key=REGULATION_MODES, ), PlugwiseSelectEntityDescription( key=SELECT_DHW_MODE, - translation_key=DHW_MODE, + translation_key=SELECT_DHW_MODE, entity_category=EntityCategory.CONFIG, options_key=DHW_MODES, ), PlugwiseSelectEntityDescription( key=SELECT_GATEWAY_MODE, - translation_key=GATEWAY_MODE, + translation_key=SELECT_GATEWAY_MODE, entity_category=EntityCategory.CONFIG, options_key=GATEWAY_MODES, ), + PlugwiseSelectEntityDescription( + key=SELECT_ZONE_PROFILE, + translation_key=SELECT_ZONE_PROFILE, + entity_category=EntityCategory.CONFIG, + options_key=ZONE_PROFILES, + ), ) diff --git a/custom_components/plugwise/strings.json b/custom_components/plugwise/strings.json index 5597dbbca..abe61ab69 100644 --- a/custom_components/plugwise/strings.json +++ b/custom_components/plugwise/strings.json @@ -113,7 +113,7 @@ } }, "select": { - "dhw_mode": { + "select_dhw_mode": { "name": "DHW mode", "state": { "auto": "Auto", @@ -122,7 +122,7 @@ "off": "Off" } }, - "regulation_mode": { + "select_regulation_mode": { "name": "Regulation mode", "state": { "bleeding_cold": "Bleeding cold", @@ -132,7 +132,7 @@ "off": "Off" } }, - "gateway_mode": { + "select_gateway_mode": { "name": "Gateway mode", "state": { "away": "Pause", @@ -145,6 +145,14 @@ "state": { "off": "Off" } + }, + "select_zone_profile": { + "name": "Zone profile", + "state": { + "active": "Active", + "off": "Off", + "passive": "Passive" + } } }, "sensor": { diff --git a/custom_components/plugwise/translations/en.json b/custom_components/plugwise/translations/en.json index 59880d357..8d2f26d06 100644 --- a/custom_components/plugwise/translations/en.json +++ b/custom_components/plugwise/translations/en.json @@ -96,7 +96,7 @@ } }, "select": { - "dhw_mode": { + "select_dhw_mode": { "name": "DHW mode", "state": { "auto": "Auto", @@ -105,7 +105,7 @@ "off": "Off" } }, - "gateway_mode": { + "select_gateway_mode": { "name": "Gateway mode", "state": { "away": "Pause", @@ -113,7 +113,7 @@ "vacation": "Vacation" } }, - "regulation_mode": { + "select_regulation_mode": { "name": "Regulation mode", "state": { "bleeding_cold": "Bleeding cold", @@ -128,6 +128,14 @@ "state": { "off": "Off" } + }, + "select_zone_profile": { + "name": "Zone profile", + "state": { + "active": "Active", + "off": "Off", + "passive": "Passive" + } } }, "sensor": { diff --git a/custom_components/plugwise/translations/nl.json b/custom_components/plugwise/translations/nl.json index aabf035dd..5cd6e90b2 100644 --- a/custom_components/plugwise/translations/nl.json +++ b/custom_components/plugwise/translations/nl.json @@ -111,7 +111,7 @@ } }, "select": { - "dhw_mode": { + "select_dhw_mode": { "name": "Modus huishoudelijk warmwater", "state": { "auto": "Auto", @@ -120,7 +120,7 @@ "off": "Uit" } }, - "regulation_mode": { + "select_regulation_mode": { "name": "Regelmodus", "state": { "bleeding_cold": "Koud ontluchten", @@ -130,7 +130,7 @@ "off": "Uit" } }, - "gateway_mode": { + "select_gateway_mode": { "name": "Gateway mode", "state": { "away": "Pauze", @@ -143,6 +143,14 @@ "state": { "off": "Uit" } + }, + "select_zone_profile": { + "name": "Zone profiel", + "state": { + "active": "Actief", + "off": "Uit", + "passive": "Passief" + } } }, "sensor": { diff --git a/tests/components/plugwise/fixtures/adam_plus_anna_new/data.json b/tests/components/plugwise/fixtures/adam_plus_anna_new/data.json index 421d5387d..ee4ecd743 100644 --- a/tests/components/plugwise/fixtures/adam_plus_anna_new/data.json +++ b/tests/components/plugwise/fixtures/adam_plus_anna_new/data.json @@ -280,6 +280,7 @@ "name": "Living room", "preset_modes": ["vacation", "no_frost", "asleep", "home", "away"], "select_schedule": "Weekschema", + "select_zone_profile": "active", "sensors": { "electricity_consumed": 60.8, "electricity_produced": 0.0, @@ -299,7 +300,8 @@ ], "secondary": [] }, - "vendor": "Plugwise" + "vendor": "Plugwise", + "zone_profiles": ["active", "off", "passive"] }, "f871b8c4d63549319221e294e4f88074": { "active_preset": "vacation", @@ -317,6 +319,7 @@ "name": "Bathroom", "preset_modes": ["vacation", "no_frost", "asleep", "home", "away"], "select_schedule": "off", + "select_zone_profile": "passive", "sensors": { "electricity_consumed": 0.0, "electricity_produced": 0.0, @@ -332,6 +335,7 @@ "primary": ["e2f4322d57924fa090fbbc48b3a140dc"], "secondary": ["1772a4ea304041adb83f357b751341ff"] }, - "vendor": "Plugwise" + "vendor": "Plugwise", + "zone_profiles": ["active", "off", "passive"] } } diff --git a/tests/components/plugwise/fixtures/m_adam_cooling/data.json b/tests/components/plugwise/fixtures/m_adam_cooling/data.json index 162bc1d2c..fdd52b1ef 100644 --- a/tests/components/plugwise/fixtures/m_adam_cooling/data.json +++ b/tests/components/plugwise/fixtures/m_adam_cooling/data.json @@ -196,6 +196,7 @@ "name": "Living room", "preset_modes": ["vacation", "no_frost", "asleep", "home", "away"], "select_schedule": "off", + "select_zone_profile": "active", "sensors": { "electricity_consumed": 60.8, "electricity_produced": 0.0, @@ -215,7 +216,8 @@ ], "secondary": [] }, - "vendor": "Plugwise" + "vendor": "Plugwise", + "zone_profiles": ["active", "off", "passive"] }, "f871b8c4d63549319221e294e4f88074": { "active_preset": "vacation", @@ -233,6 +235,7 @@ "name": "Bathroom", "preset_modes": ["vacation", "no_frost", "asleep", "home", "away"], "select_schedule": "off", + "select_zone_profile": "passive", "sensors": { "electricity_consumed": 0.0, "electricity_produced": 0.0, @@ -248,6 +251,7 @@ "primary": ["e2f4322d57924fa090fbbc48b3a140dc"], "secondary": ["1772a4ea304041adb83f357b751341ff"] }, - "vendor": "Plugwise" + "vendor": "Plugwise", + "zone_profiles": ["active", "off", "passive"] } } diff --git a/tests/components/plugwise/fixtures/m_adam_heating/data.json b/tests/components/plugwise/fixtures/m_adam_heating/data.json index 87378f5b2..2f3951c0c 100644 --- a/tests/components/plugwise/fixtures/m_adam_heating/data.json +++ b/tests/components/plugwise/fixtures/m_adam_heating/data.json @@ -195,6 +195,7 @@ "name": "Living room", "preset_modes": ["vacation", "no_frost", "asleep", "home", "away"], "select_schedule": "off", + "select_zone_profile": "active", "sensors": { "electricity_consumed": 60.8, "electricity_produced": 0.0, @@ -214,7 +215,8 @@ ], "secondary": [] }, - "vendor": "Plugwise" + "vendor": "Plugwise", + "zone_profiles": ["active", "off", "passive"] }, "f871b8c4d63549319221e294e4f88074": { "active_preset": "vacation", @@ -232,6 +234,7 @@ "name": "Bathroom", "preset_modes": ["vacation", "no_frost", "asleep", "home", "away"], "select_schedule": "off", + "select_zone_profile": "passive", "sensors": { "electricity_consumed": 0.0, "electricity_produced": 0.0, @@ -247,6 +250,7 @@ "primary": ["e2f4322d57924fa090fbbc48b3a140dc"], "secondary": ["1772a4ea304041adb83f357b751341ff"] }, - "vendor": "Plugwise" + "vendor": "Plugwise", + "zone_profiles": ["active", "off", "passive"] } } diff --git a/tests/components/plugwise/fixtures/m_adam_jip/data.json b/tests/components/plugwise/fixtures/m_adam_jip/data.json index 50b9a8109..c9ffb7395 100644 --- a/tests/components/plugwise/fixtures/m_adam_jip/data.json +++ b/tests/components/plugwise/fixtures/m_adam_jip/data.json @@ -8,6 +8,7 @@ "name": "Slaapkamer", "preset_modes": ["home", "asleep", "away", "vacation", "no_frost"], "select_schedule": null, + "select_zone_profile": "active", "sensors": { "temperature": 24.2 }, @@ -21,7 +22,8 @@ "primary": ["1346fbd8498d4dbcab7e18d51b771f3d"], "secondary": ["356b65335e274d769c338223e7af9c33"] }, - "vendor": "Plugwise" + "vendor": "Plugwise", + "zone_profiles": ["active", "off", "passive"] }, "13228dab8ce04617af318a2888b3c548": { "active_preset": "home", @@ -33,6 +35,7 @@ "name": "Woonkamer", "preset_modes": ["home", "asleep", "away", "vacation", "no_frost"], "select_schedule": null, + "select_zone_profile": "active", "sensors": { "temperature": 27.4 }, @@ -46,7 +49,8 @@ "primary": ["f61f1a2535f54f52ad006a3d18e459ca"], "secondary": ["833de10f269c4deab58fb9df69901b4e"] }, - "vendor": "Plugwise" + "vendor": "Plugwise", + "zone_profiles": ["active", "off", "passive"] }, "1346fbd8498d4dbcab7e18d51b771f3d": { "available": true, @@ -248,6 +252,7 @@ "name": "Kinderkamer", "preset_modes": ["home", "asleep", "away", "vacation", "no_frost"], "select_schedule": null, + "select_zone_profile": "active", "sensors": { "temperature": 30.0 }, @@ -261,7 +266,8 @@ "primary": ["6f3e9d7084214c21b9dfa46f6eeb8700"], "secondary": ["d4496250d0e942cfa7aea3476e9070d5"] }, - "vendor": "Plugwise" + "vendor": "Plugwise", + "zone_profiles": ["active", "off", "passive"] }, "d4496250d0e942cfa7aea3476e9070d5": { "available": true, @@ -297,6 +303,7 @@ "name": "Logeerkamer", "preset_modes": ["home", "asleep", "away", "vacation", "no_frost"], "select_schedule": null, + "select_zone_profile": "active", "sensors": { "temperature": 30.0 }, @@ -310,7 +317,8 @@ "primary": ["a6abc6a129ee499c88a4d420cc413b47"], "secondary": ["1da4d325838e4ad8aac12177214505c9"] }, - "vendor": "Plugwise" + "vendor": "Plugwise", + "zone_profiles": ["active", "off", "passive"] }, "e4684553153b44afbef2200885f379dc": { "available": true, diff --git a/tests/components/plugwise/snapshots/test_select.ambr b/tests/components/plugwise/snapshots/test_select.ambr index 39275b56c..403877438 100644 --- a/tests/components/plugwise/snapshots/test_select.ambr +++ b/tests/components/plugwise/snapshots/test_select.ambr @@ -184,6 +184,65 @@ 'state': 'off', }) # --- +# name: test_adam_2_select_entities[platforms0-True-m_adam_cooling][select.bathroom_zone_profile-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': dict({ + 'options': list([ + 'active', + 'off', + 'passive', + ]), + }), + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'select', + 'entity_category': , + 'entity_id': 'select.bathroom_zone_profile', + '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': 'Zone profile', + 'platform': 'plugwise', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': 'select_zone_profile', + 'unique_id': 'f871b8c4d63549319221e294e4f88074-select_zone_profile', + 'unit_of_measurement': None, + }) +# --- +# name: test_adam_2_select_entities[platforms0-True-m_adam_cooling][select.bathroom_zone_profile-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'Bathroom Zone profile', + 'options': list([ + 'active', + 'off', + 'passive', + ]), + }), + 'context': , + 'entity_id': 'select.bathroom_zone_profile', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'passive', + }) +# --- # name: test_adam_2_select_entities[platforms0-True-m_adam_cooling][select.living_room_thermostat_schedule-entry] EntityRegistryEntrySnapshot({ 'aliases': set({ @@ -247,6 +306,65 @@ 'state': 'off', }) # --- +# name: test_adam_2_select_entities[platforms0-True-m_adam_cooling][select.living_room_zone_profile-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': dict({ + 'options': list([ + 'active', + 'off', + 'passive', + ]), + }), + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'select', + 'entity_category': , + 'entity_id': 'select.living_room_zone_profile', + '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': 'Zone profile', + 'platform': 'plugwise', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': 'select_zone_profile', + 'unique_id': 'f2bf9048bef64cc5b6d5110154e33c81-select_zone_profile', + 'unit_of_measurement': None, + }) +# --- +# name: test_adam_2_select_entities[platforms0-True-m_adam_cooling][select.living_room_zone_profile-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'Living room Zone profile', + 'options': list([ + 'active', + 'off', + 'passive', + ]), + }), + 'context': , + 'entity_id': 'select.living_room_zone_profile', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'active', + }) +# --- # name: test_adam_select_entities[platforms0][select.badkamer_thermostat_schedule-entry] EntityRegistryEntrySnapshot({ 'aliases': set({ diff --git a/tests/components/plugwise/test_init.py b/tests/components/plugwise/test_init.py index 5e04297a4..4a4d69368 100644 --- a/tests/components/plugwise/test_init.py +++ b/tests/components/plugwise/test_init.py @@ -297,7 +297,7 @@ async def test_update_device( assert ( len(er.async_entries_for_config_entry(entity_registry, mock_config_entry.entry_id)) - == 49 + == 51 ) assert ( len(dr.async_entries_for_config_entry(device_registry, mock_config_entry.entry_id)) @@ -321,7 +321,7 @@ async def test_update_device( assert ( len(er.async_entries_for_config_entry(entity_registry, mock_config_entry.entry_id)) - == 56 + == 58 ) assert ( len(dr.async_entries_for_config_entry(device_registry, mock_config_entry.entry_id)) @@ -348,7 +348,7 @@ async def test_update_device( assert ( len(er.async_entries_for_config_entry(entity_registry, mock_config_entry.entry_id)) - == 49 + == 51 ) assert ( len(dr.async_entries_for_config_entry(device_registry, mock_config_entry.entry_id)) diff --git a/tests/components/plugwise/test_select.py b/tests/components/plugwise/test_select.py index e79c0738f..57ab1ec41 100644 --- a/tests/components/plugwise/test_select.py +++ b/tests/components/plugwise/test_select.py @@ -45,7 +45,6 @@ async def test_adam_change_select_entity( }, blocking=True, ) - assert mock_smile_adam.set_select.call_count == 1 mock_smile_adam.set_select.assert_called_with( "select_schedule", @@ -98,6 +97,30 @@ async def test_adam_select_regulation_mode( "on", ) +@pytest.mark.parametrize("chosen_env", ["m_adam_heating"], indirect=True) +@pytest.mark.parametrize("cooling_present", [True], indirect=True) +async def test_adam_select_zone_profile( + hass: HomeAssistant, + mock_smile_adam_heat_cool: MagicMock, + init_integration: MockConfigEntry, +) -> None: + """Test changing the zone_profile select.""" + await hass.services.async_call( + SELECT_DOMAIN, + SERVICE_SELECT_OPTION, + { + ATTR_ENTITY_ID: "select.living_room_zone_profile", + ATTR_OPTION: "passive", + }, + blocking=True, + ) + assert mock_smile_adam_heat_cool.set_select.call_count == 1 + mock_smile_adam_heat_cool.set_select.assert_called_with( + "select_zone_profile", + "f2bf9048bef64cc5b6d5110154e33c81", + "passive", + "on", + ) async def test_legacy_anna_select_entities( hass: HomeAssistant,