diff --git a/homeassistant/components/hr_energy_qube/manifest.json b/homeassistant/components/hr_energy_qube/manifest.json index 38cb452e094d..813f2bb6959c 100644 --- a/homeassistant/components/hr_energy_qube/manifest.json +++ b/homeassistant/components/hr_energy_qube/manifest.json @@ -7,6 +7,6 @@ "integration_type": "hub", "iot_class": "local_polling", "loggers": ["python_qube_heatpump"], - "quality_scale": "bronze", + "quality_scale": "silver", "requirements": ["python-qube-heatpump==1.15.0"] } diff --git a/homeassistant/components/hr_energy_qube/quality_scale.yaml b/homeassistant/components/hr_energy_qube/quality_scale.yaml index 9652c324fe89..8bcd9975b02f 100644 --- a/homeassistant/components/hr_energy_qube/quality_scale.yaml +++ b/homeassistant/components/hr_energy_qube/quality_scale.yaml @@ -32,9 +32,7 @@ rules: unique-config-entry: done # Silver - action-exceptions: - status: exempt - comment: Integration does not register custom actions. + action-exceptions: done config-entry-unloading: done docs-configuration-parameters: status: exempt diff --git a/tests/components/hr_energy_qube/test_water_heater.py b/tests/components/hr_energy_qube/test_water_heater.py index 6519ed4baa91..1e522d0bc658 100644 --- a/tests/components/hr_energy_qube/test_water_heater.py +++ b/tests/components/hr_energy_qube/test_water_heater.py @@ -14,7 +14,7 @@ from homeassistant.components.water_heater import ( STATE_HEAT_PUMP, STATE_PERFORMANCE, ) -from homeassistant.const import ATTR_ENTITY_ID, Platform +from homeassistant.const import ATTR_ENTITY_ID, STATE_UNKNOWN, Platform from homeassistant.core import HomeAssistant from homeassistant.exceptions import HomeAssistantError from homeassistant.helpers import entity_registry as er @@ -61,15 +61,26 @@ async def test_set_temperature( mock_qube_client.write_setpoint.assert_awaited_once_with("setpoint_dhw", 55) +@pytest.mark.parametrize( + ("side_effect", "return_value"), + [ + (ConnectionError, None), + (None, False), + ], +) async def test_set_temperature_failure( hass: HomeAssistant, mock_qube_client: MagicMock, mock_config_entry: MockConfigEntry, + side_effect: type[Exception] | None, + return_value: bool | None, ) -> None: """Test set temperature raises HomeAssistantError on failure.""" await setup_integration(hass, mock_config_entry) - mock_qube_client.write_setpoint = AsyncMock(return_value=False) + mock_qube_client.write_setpoint = AsyncMock( + side_effect=side_effect, return_value=return_value + ) with pytest.raises(HomeAssistantError): await hass.services.async_call( WATER_HEATER_DOMAIN, @@ -108,6 +119,35 @@ async def test_set_operation_mode( ) +@pytest.mark.parametrize( + ("side_effect", "return_value"), + [ + (ConnectionError, None), + (None, False), + ], +) +async def test_set_operation_mode_failure( + hass: HomeAssistant, + mock_qube_client: MagicMock, + mock_config_entry: MockConfigEntry, + side_effect: type[Exception] | None, + return_value: bool | None, +) -> None: + """Test set operation mode raises HomeAssistantError on failure.""" + await setup_integration(hass, mock_config_entry) + + mock_qube_client.write_switch = AsyncMock( + side_effect=side_effect, return_value=return_value + ) + with pytest.raises(HomeAssistantError): + await hass.services.async_call( + WATER_HEATER_DOMAIN, + SERVICE_SET_OPERATION_MODE, + {ATTR_ENTITY_ID: ENTITY_ID, ATTR_OPERATION_MODE: STATE_PERFORMANCE}, + blocking=True, + ) + + async def test_current_operation_boost( hass: HomeAssistant, mock_qube_client: MagicMock, @@ -122,3 +162,19 @@ async def test_current_operation_boost( state = hass.states.get(ENTITY_ID) assert state is not None assert state.attributes["operation_mode"] == STATE_PERFORMANCE + + +async def test_current_operation_unknown( + hass: HomeAssistant, + mock_qube_client: MagicMock, + mock_config_entry: MockConfigEntry, +) -> None: + """Test current operation is unknown when the boost coil cannot be read.""" + mock_qube_client.read_all_switches.return_value["tapw_timeprogram_bms_forced"] = ( + None + ) + await setup_integration(hass, mock_config_entry) + + state = hass.states.get(ENTITY_ID) + assert state is not None + assert state.state == STATE_UNKNOWN