mirror of
https://github.com/home-assistant/core.git
synced 2025-07-24 21:57:51 +00:00
Plugwise Quality improvements (#132175)
This commit is contained in:
parent
a4ceed776e
commit
421e2411d3
@ -15,7 +15,7 @@ from homeassistant.components.climate import (
|
|||||||
)
|
)
|
||||||
from homeassistant.const import ATTR_TEMPERATURE, UnitOfTemperature
|
from homeassistant.const import ATTR_TEMPERATURE, UnitOfTemperature
|
||||||
from homeassistant.core import HomeAssistant, callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
from homeassistant.exceptions import HomeAssistantError
|
from homeassistant.exceptions import ServiceValidationError
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
|
||||||
from . import PlugwiseConfigEntry
|
from . import PlugwiseConfigEntry
|
||||||
@ -226,12 +226,6 @@ class PlugwiseClimateEntity(PlugwiseEntity, ClimateEntity):
|
|||||||
if ATTR_TARGET_TEMP_LOW in kwargs:
|
if ATTR_TARGET_TEMP_LOW in kwargs:
|
||||||
data["setpoint_low"] = kwargs.get(ATTR_TARGET_TEMP_LOW)
|
data["setpoint_low"] = kwargs.get(ATTR_TARGET_TEMP_LOW)
|
||||||
|
|
||||||
for temperature in data.values():
|
|
||||||
if temperature is None or not (
|
|
||||||
self._attr_min_temp <= temperature <= self._attr_max_temp
|
|
||||||
):
|
|
||||||
raise ValueError("Invalid temperature change requested")
|
|
||||||
|
|
||||||
if mode := kwargs.get(ATTR_HVAC_MODE):
|
if mode := kwargs.get(ATTR_HVAC_MODE):
|
||||||
await self.async_set_hvac_mode(mode)
|
await self.async_set_hvac_mode(mode)
|
||||||
|
|
||||||
@ -241,7 +235,15 @@ class PlugwiseClimateEntity(PlugwiseEntity, ClimateEntity):
|
|||||||
async def async_set_hvac_mode(self, hvac_mode: HVACMode) -> None:
|
async def async_set_hvac_mode(self, hvac_mode: HVACMode) -> None:
|
||||||
"""Set the hvac mode."""
|
"""Set the hvac mode."""
|
||||||
if hvac_mode not in self.hvac_modes:
|
if hvac_mode not in self.hvac_modes:
|
||||||
raise HomeAssistantError("Unsupported hvac_mode")
|
hvac_modes = ", ".join(self.hvac_modes)
|
||||||
|
raise ServiceValidationError(
|
||||||
|
translation_domain=DOMAIN,
|
||||||
|
translation_key="unsupported_hvac_mode_requested",
|
||||||
|
translation_placeholders={
|
||||||
|
"hvac_mode": hvac_mode,
|
||||||
|
"hvac_modes": hvac_modes,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
if hvac_mode == self.hvac_mode:
|
if hvac_mode == self.hvac_mode:
|
||||||
return
|
return
|
||||||
|
@ -68,7 +68,6 @@ class PlugwiseDataUpdateCoordinator(DataUpdateCoordinator[PlugwiseData]):
|
|||||||
|
|
||||||
async def _async_update_data(self) -> PlugwiseData:
|
async def _async_update_data(self) -> PlugwiseData:
|
||||||
"""Fetch data from Plugwise."""
|
"""Fetch data from Plugwise."""
|
||||||
data = PlugwiseData(devices={}, gateway={})
|
|
||||||
try:
|
try:
|
||||||
if not self._connected:
|
if not self._connected:
|
||||||
await self._connect()
|
await self._connect()
|
||||||
@ -85,9 +84,8 @@ class PlugwiseDataUpdateCoordinator(DataUpdateCoordinator[PlugwiseData]):
|
|||||||
raise UpdateFailed("Data incomplete or missing") from err
|
raise UpdateFailed("Data incomplete or missing") from err
|
||||||
except UnsupportedDeviceError as err:
|
except UnsupportedDeviceError as err:
|
||||||
raise ConfigEntryError("Device with unsupported firmware") from err
|
raise ConfigEntryError("Device with unsupported firmware") from err
|
||||||
else:
|
|
||||||
self._async_add_remove_devices(data, self.config_entry)
|
|
||||||
|
|
||||||
|
self._async_add_remove_devices(data, self.config_entry)
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def _async_add_remove_devices(self, data: PlugwiseData, entry: ConfigEntry) -> None:
|
def _async_add_remove_devices(self, data: PlugwiseData, entry: ConfigEntry) -> None:
|
||||||
|
@ -8,26 +8,22 @@ rules:
|
|||||||
config-flow-test-coverage:
|
config-flow-test-coverage:
|
||||||
status: todo
|
status: todo
|
||||||
comment: Cover test_form and zeroconf
|
comment: Cover test_form and zeroconf
|
||||||
runtime-data:
|
runtime-data: done
|
||||||
status: todo
|
|
||||||
comment: Clean up test_init for testing internals
|
|
||||||
test-before-setup: done
|
test-before-setup: done
|
||||||
appropriate-polling:
|
appropriate-polling: done
|
||||||
status: todo
|
|
||||||
comment: Clean up coordinator (L71) check for mypy happiness
|
|
||||||
entity-unique-id: done
|
entity-unique-id: done
|
||||||
has-entity-name: done
|
has-entity-name: done
|
||||||
entity-event-setup: done
|
entity-event-setup: done
|
||||||
dependency-transparency: done
|
dependency-transparency: done
|
||||||
action-setup:
|
action-setup:
|
||||||
status: todo
|
status: exempt
|
||||||
comment: Check if we have these, otherwise exempt
|
comment: Plugwise integration has no custom actions
|
||||||
common-modules:
|
common-modules:
|
||||||
status: todo
|
status: todo
|
||||||
comment: Verify entity for async_added_to_hass usage (discard?)
|
comment: Verify entity for async_added_to_hass usage (discard?)
|
||||||
docs-high-level-description:
|
docs-high-level-description:
|
||||||
status: todo
|
status: todo
|
||||||
comment: Rewrite top section
|
comment: Rewrite top section, docs PR prepared
|
||||||
docs-installation-instructions:
|
docs-installation-instructions:
|
||||||
status: todo
|
status: todo
|
||||||
comment: Docs PR 36087
|
comment: Docs PR 36087
|
||||||
@ -38,9 +34,7 @@ rules:
|
|||||||
config-entry-unloading: done
|
config-entry-unloading: done
|
||||||
log-when-unavailable: done
|
log-when-unavailable: done
|
||||||
entity-unavailable: done
|
entity-unavailable: done
|
||||||
action-exceptions:
|
action-exceptions: done
|
||||||
status: todo
|
|
||||||
comment: Climate exception on ValueError should be ServiceValidationError
|
|
||||||
reauthentication-flow:
|
reauthentication-flow:
|
||||||
status: exempt
|
status: exempt
|
||||||
comment: The hubs have a hardcoded `Smile ID` printed on the sticker used as password, it can not be changed
|
comment: The hubs have a hardcoded `Smile ID` printed on the sticker used as password, it can not be changed
|
||||||
@ -53,7 +47,7 @@ rules:
|
|||||||
integration-owner: done
|
integration-owner: done
|
||||||
docs-installation-parameters:
|
docs-installation-parameters:
|
||||||
status: todo
|
status: todo
|
||||||
comment: Docs PR 36087 (partial) + todo rewrite generically
|
comment: Docs PR 36087 (partial) + todo rewrite generically (PR prepared)
|
||||||
docs-configuration-parameters:
|
docs-configuration-parameters:
|
||||||
status: exempt
|
status: exempt
|
||||||
comment: Plugwise has no options flow
|
comment: Plugwise has no options flow
|
||||||
@ -68,34 +62,32 @@ rules:
|
|||||||
diagnostics: done
|
diagnostics: done
|
||||||
exception-translations:
|
exception-translations:
|
||||||
status: todo
|
status: todo
|
||||||
comment: Add coordinator, util and climate exceptions
|
comment: Add coordinator, util exceptions (climate done in core 132175)
|
||||||
icon-translations: done
|
icon-translations: done
|
||||||
reconfiguration-flow:
|
reconfiguration-flow:
|
||||||
status: todo
|
status: todo
|
||||||
comment: This integration does not have any reconfiguration steps (yet) investigate how/why
|
comment: This integration does not have any reconfiguration steps (yet) investigate how/why
|
||||||
dynamic-devices:
|
dynamic-devices: done
|
||||||
status: todo
|
|
||||||
comment: Add missing logic to button for unloading and creation
|
|
||||||
discovery-update-info: done
|
discovery-update-info: done
|
||||||
repair-issues:
|
repair-issues:
|
||||||
status: exempt
|
status: exempt
|
||||||
comment: This integration does not have repairs
|
comment: This integration does not have repairs
|
||||||
docs-use-cases:
|
docs-use-cases:
|
||||||
status: todo
|
status: todo
|
||||||
comment: Check for completeness
|
comment: Check for completeness, PR prepared
|
||||||
docs-supported-devices:
|
docs-supported-devices:
|
||||||
status: todo
|
status: todo
|
||||||
comment: The list is there but could be improved for readability
|
comment: The list is there but could be improved for readability, PR prepared
|
||||||
docs-supported-functions:
|
docs-supported-functions:
|
||||||
status: todo
|
status: todo
|
||||||
comment: Check for completeness
|
comment: Check for completeness
|
||||||
docs-data-update: done
|
docs-data-update: done
|
||||||
docs-known-limitations:
|
docs-known-limitations:
|
||||||
status: todo
|
status: todo
|
||||||
comment: Partial in 36087 but could be more elaborat
|
comment: Partial in 36087 but could be more elaborate
|
||||||
docs-troubleshooting:
|
docs-troubleshooting:
|
||||||
status: todo
|
status: todo
|
||||||
comment: Check for completeness
|
comment: Check for completeness, PR prepared
|
||||||
docs-examples:
|
docs-examples:
|
||||||
status: todo
|
status: todo
|
||||||
comment: Check for completeness
|
comment: Check for completeness
|
||||||
|
@ -284,5 +284,13 @@
|
|||||||
"name": "Relay"
|
"name": "Relay"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"exceptions": {
|
||||||
|
"invalid_temperature_change_requested": {
|
||||||
|
"message": "Invalid temperature change requested."
|
||||||
|
},
|
||||||
|
"unsupported_hvac_mode_requested": {
|
||||||
|
"message": "Unsupported mode {hvac_mode} requested, valid modes are: {hvac_modes}."
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -233,7 +233,7 @@ async def test_adam_climate_entity_climate_changes(
|
|||||||
"c50f167537524366a5af7aa3942feb1e", "off"
|
"c50f167537524366a5af7aa3942feb1e", "off"
|
||||||
)
|
)
|
||||||
|
|
||||||
with pytest.raises(HomeAssistantError):
|
with pytest.raises(ServiceValidationError):
|
||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
CLIMATE_DOMAIN,
|
CLIMATE_DOMAIN,
|
||||||
SERVICE_SET_HVAC_MODE,
|
SERVICE_SET_HVAC_MODE,
|
||||||
|
@ -78,7 +78,6 @@ async def test_load_unload_config_entry(
|
|||||||
await hass.config_entries.async_unload(mock_config_entry.entry_id)
|
await hass.config_entries.async_unload(mock_config_entry.entry_id)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert not hass.data.get(DOMAIN)
|
|
||||||
assert mock_config_entry.state is ConfigEntryState.NOT_LOADED
|
assert mock_config_entry.state is ConfigEntryState.NOT_LOADED
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user