diff --git a/homeassistant/components/hotspring/diagnostics.py b/homeassistant/components/hotspring/diagnostics.py index 889fe04fded9..44e3b7235212 100644 --- a/homeassistant/components/hotspring/diagnostics.py +++ b/homeassistant/components/hotspring/diagnostics.py @@ -41,15 +41,17 @@ async def async_get_config_entry_diagnostics( "data": { "info": info, "heater": asdict(spa.heater), - "jets": [asdict(jet) for jet in spa.jets], + "jets": [asdict(jet) for jet in spa.jets.values()], "blower": asdict(spa.blower), - "light_zones": [asdict(zone) for zone in spa.light_zones], + "light_zones": [asdict(zone) for zone in spa.light_zones.values()], "logo_light": asdict(spa.logo_light), "clean_cycle": asdict(spa.clean_cycle), "spa_lock": asdict(spa.spa_lock), "water_care": asdict(spa.water_care), "freshwater_iq": asdict(spa.freshwater_iq), - "energy_savings": [asdict(schedule) for schedule in spa.energy_savings], + "energy_savings": [ + asdict(schedule) for schedule in spa.energy_savings.values() + ], "versions": asdict(spa.versions), "connection_status": asdict(spa.connection_status), "diagnostics": asdict(spa.diagnostics), diff --git a/homeassistant/components/hotspring/light.py b/homeassistant/components/hotspring/light.py index 83b371be4832..96e5060874b9 100644 --- a/homeassistant/components/hotspring/light.py +++ b/homeassistant/components/hotspring/light.py @@ -40,7 +40,7 @@ async def async_setup_entry( coordinator = entry.runtime_data async_add_entities( HotSpringLightEntity(coordinator, zone.zone_id) - for zone in coordinator.data.light_zones + for zone in coordinator.data.light_zones.values() if zone.is_enabled ) @@ -65,10 +65,7 @@ class HotSpringLightEntity(HotSpringEntity, LightEntity): @property def _zone(self) -> LightZone: """Return the light zone data.""" - for zone in self.coordinator.data.light_zones: - if zone.zone_id == self._zone_id: - return zone - raise AssertionError("Light zone must exist in coordinator data") + return self.coordinator.data.light_zones[self._zone_id] @property @override diff --git a/homeassistant/components/hotspring/manifest.json b/homeassistant/components/hotspring/manifest.json index 3b577f5df72d..3bdb7992571b 100644 --- a/homeassistant/components/hotspring/manifest.json +++ b/homeassistant/components/hotspring/manifest.json @@ -8,7 +8,7 @@ "iot_class": "local_polling", "loggers": ["hotspring"], "quality_scale": "platinum", - "requirements": ["python-hotspring==2.1.0"], + "requirements": ["python-hotspring==3.0.0"], "zeroconf": [ { "name": "watkins_spa*", diff --git a/requirements_all.txt b/requirements_all.txt index c16d96e52a8e..2e6c5ee99452 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -2756,7 +2756,7 @@ python-homeassistant-analytics==0.9.0 python-homewizard-energy==10.2.0 # homeassistant.components.hotspring -python-hotspring==2.1.0 +python-hotspring==3.0.0 # homeassistant.components.hp_ilo python-hpilo==4.4.3 diff --git a/tests/components/hotspring/conftest.py b/tests/components/hotspring/conftest.py index 3cf62812ed6f..c7d66bb6a40f 100644 --- a/tests/components/hotspring/conftest.py +++ b/tests/components/hotspring/conftest.py @@ -107,13 +107,13 @@ def device_fixture() -> Spa: boost_active=False, salt_value=12, ) - spa.jets = [ - Jet(jet_id=1, speed=JetSpeed.OFF, is_enabled=True, on_seconds=0), - Jet(jet_id=2, speed=JetSpeed.OFF, is_enabled=True, on_seconds=0), - ] + spa.jets = { + 1: Jet(jet_id=1, speed=JetSpeed.OFF, is_enabled=True, on_seconds=0), + 2: Jet(jet_id=2, speed=JetSpeed.OFF, is_enabled=True, on_seconds=0), + } spa.blower = Blower(is_enabled=False, is_on=False) - spa.light_zones = [ - LightZone( + spa.light_zones = { + 1: LightZone( zone_id=1, is_enabled=True, is_on=False, @@ -122,7 +122,7 @@ def device_fixture() -> Spa: intensity=0, loop_speed=0, ), - ] + } spa.logo_light = LogoLight(brightness=BrightnessLevel.LEVEL_1) spa.clean_cycle = CleanCycle(is_enabled=False, vanishing_act=False) spa.spa_lock = SpaLock(is_locked=False) @@ -134,9 +134,11 @@ def device_fixture() -> Spa: sensor_life_percentage=100.0, installed=False, ) - spa.energy_savings = [ - EnergySaving(schedule_id=1, mode=0, start_hour=0, start_minute=0, duration=0), - ] + spa.energy_savings = { + 1: EnergySaving( + schedule_id=1, mode=0, start_hour=0, start_minute=0, duration=0 + ), + } spa.connection_status = ConnectionStatus(spa_connected=True) spa.diagnostics = Diagnostics( spa_failure_state=SpaFailureState.OK, diff --git a/tests/components/hotspring/snapshots/test_diagnostics.ambr b/tests/components/hotspring/snapshots/test_diagnostics.ambr index 36b8e021c4f5..007f53ff7a1c 100644 --- a/tests/components/hotspring/snapshots/test_diagnostics.ambr +++ b/tests/components/hotspring/snapshots/test_diagnostics.ambr @@ -7,13 +7,17 @@ 'is_on': False, }), 'clean_cycle': dict({ + 'clean_timer_enabled': False, 'is_enabled': False, + 'start_hour': 0, + 'start_minute': 0, 'vanishing_act': False, }), 'connection_status': dict({ 'spa_connected': True, }), 'diagnostics': dict({ + 'circulation_pump_flow_status': '0', 'heater_error': '0', 'heater_power': '0', 'heater_volts': 240.0, @@ -22,8 +26,10 @@ 'jet3_volts': 0.0, 'l1_n_volts': 120.0, 'l2_n_volts': 120.0, + 'limit_thermistor_status': '0', 'power_frequency': '60', 'pressure_switch_status': '0', + 'regulation_thermistor_temp_status': '0', 'small_loads_power': '0', 'spa_failure_state': dict({ '__type': "", @@ -82,6 +88,8 @@ }), 'jets': list([ dict({ + 'concurrent_mode': False, + 'current': 0.0, 'is_enabled': True, 'jet_id': 1, 'on_seconds': 0, @@ -89,8 +97,14 @@ '__type': "", 'repr': "", }), + 'speed_type': dict({ + '__type': "", + 'repr': "", + }), }), dict({ + 'concurrent_mode': False, + 'current': 0.0, 'is_enabled': True, 'jet_id': 2, 'on_seconds': 0, @@ -98,6 +112,10 @@ '__type': "", 'repr': "", }), + 'speed_type': dict({ + '__type': "", + 'repr': "", + }), }), ]), 'light_zones': list([ @@ -157,6 +175,8 @@ 'cartridge_installed': True, 'level': 2, 'one_twenty_day_timer': 117, + 'power_a': False, + 'power_b': False, 'salt_value': 12, 'system_enabled': True, 'ten_day_timer': 0, @@ -175,13 +195,17 @@ 'is_on': False, }), 'clean_cycle': dict({ + 'clean_timer_enabled': False, 'is_enabled': False, + 'start_hour': 0, + 'start_minute': 0, 'vanishing_act': False, }), 'connection_status': dict({ 'spa_connected': True, }), 'diagnostics': dict({ + 'circulation_pump_flow_status': '0', 'heater_error': '0', 'heater_power': '0', 'heater_volts': 240.0, @@ -190,8 +214,10 @@ 'jet3_volts': 0.0, 'l1_n_volts': 120.0, 'l2_n_volts': 120.0, + 'limit_thermistor_status': '0', 'power_frequency': '60', 'pressure_switch_status': '0', + 'regulation_thermistor_temp_status': '0', 'small_loads_power': '0', 'spa_failure_state': dict({ '__type': "", @@ -250,6 +276,8 @@ }), 'jets': list([ dict({ + 'concurrent_mode': False, + 'current': 0.0, 'is_enabled': True, 'jet_id': 1, 'on_seconds': 0, @@ -257,8 +285,14 @@ '__type': "", 'repr': "", }), + 'speed_type': dict({ + '__type': "", + 'repr': "", + }), }), dict({ + 'concurrent_mode': False, + 'current': 0.0, 'is_enabled': True, 'jet_id': 2, 'on_seconds': 0, @@ -266,6 +300,10 @@ '__type': "", 'repr': "", }), + 'speed_type': dict({ + '__type': "", + 'repr': "", + }), }), ]), 'light_zones': list([ @@ -325,6 +363,8 @@ 'cartridge_installed': True, 'level': 2, 'one_twenty_day_timer': 117, + 'power_a': False, + 'power_b': False, 'salt_value': 12, 'system_enabled': True, 'ten_day_timer': 0, diff --git a/tests/components/hotspring/test_light.py b/tests/components/hotspring/test_light.py index 4d247af26918..7eeaad9d9f22 100644 --- a/tests/components/hotspring/test_light.py +++ b/tests/components/hotspring/test_light.py @@ -60,8 +60,8 @@ async def test_turn_on_default( assert state.attributes.get(ATTR_BRIGHTNESS) is None def _set_light_brightness(zone: int, brightness: int) -> None: - device_fixture.light_zones[0].intensity = brightness - device_fixture.light_zones[0].is_on = brightness > 0 + device_fixture.light_zones[1].intensity = brightness + device_fixture.light_zones[1].is_on = brightness > 0 mock_hotspring.set_light_brightness.side_effect = _set_light_brightness @@ -88,8 +88,8 @@ async def test_turn_on_with_brightness( """Test turning on light with brightness.""" def _set_light_brightness(zone: int, brightness: int) -> None: - device_fixture.light_zones[0].intensity = brightness - device_fixture.light_zones[0].is_on = brightness > 0 + device_fixture.light_zones[1].intensity = brightness + device_fixture.light_zones[1].is_on = brightness > 0 mock_hotspring.set_light_brightness.side_effect = _set_light_brightness @@ -137,8 +137,8 @@ async def test_turn_on_with_rgb_color_when_on( device_fixture: Spa, ) -> None: """Test setting rgb color when light is already on.""" - device_fixture.light_zones = [ - LightZone( + device_fixture.light_zones = { + 1: LightZone( zone_id=1, is_enabled=True, is_on=True, @@ -147,7 +147,7 @@ async def test_turn_on_with_rgb_color_when_on( intensity=3, loop_speed=0, ), - ] + } await setup_with_selected_platforms(hass, mock_config_entry, [Platform.LIGHT]) await hass.services.async_call( @@ -192,8 +192,8 @@ async def test_rgb_color_active_custom( device_fixture: Spa, ) -> None: """Test rgb_color property returns custom RGB values when active.""" - device_fixture.light_zones = [ - LightZone( + device_fixture.light_zones = { + 1: LightZone( zone_id=1, is_enabled=True, is_on=True, @@ -206,7 +206,7 @@ async def test_rgb_color_active_custom( c_blue=50, rgb_state="active", ), - ] + } await setup_with_selected_platforms(hass, mock_config_entry, [Platform.LIGHT]) state = hass.states.get(ENTITY_ID) @@ -221,8 +221,8 @@ async def test_rgb_color_all_zero( device_fixture: Spa, ) -> None: """Test rgb_color property returns (0, 0, 0) when rgb_state is active.""" - device_fixture.light_zones = [ - LightZone( + device_fixture.light_zones = { + 1: LightZone( zone_id=1, is_enabled=True, is_on=True, @@ -235,7 +235,7 @@ async def test_rgb_color_all_zero( c_blue=0, rgb_state="active", ), - ] + } await setup_with_selected_platforms(hass, mock_config_entry, [Platform.LIGHT]) state = hass.states.get(ENTITY_ID) @@ -250,8 +250,8 @@ async def test_turn_off( device_fixture: Spa, ) -> None: """Test turning off light.""" - device_fixture.light_zones = [ - LightZone( + device_fixture.light_zones = { + 1: LightZone( zone_id=1, is_enabled=True, is_on=True, @@ -260,12 +260,12 @@ async def test_turn_off( intensity=5, loop_speed=0, ), - ] + } await setup_with_selected_platforms(hass, mock_config_entry, [Platform.LIGHT]) def _turn_off_light(zone: int) -> None: - device_fixture.light_zones[0].intensity = 0 - device_fixture.light_zones[0].is_on = False + device_fixture.light_zones[1].intensity = 0 + device_fixture.light_zones[1].is_on = False mock_hotspring.turn_off_light.side_effect = _turn_off_light @@ -352,8 +352,8 @@ async def test_disabled_zone_not_added( entity_registry: er.EntityRegistry, ) -> None: """Test disabled light zones are not added to entity registry.""" - device_fixture.light_zones = [ - LightZone( + device_fixture.light_zones = { + 1: LightZone( zone_id=1, is_enabled=False, is_on=False, @@ -362,7 +362,7 @@ async def test_disabled_zone_not_added( intensity=0, loop_speed=0, ), - ] + } await setup_with_selected_platforms(hass, mock_config_entry, [Platform.LIGHT]) assert not entity_registry.async_is_registered(ENTITY_ID)