Add domestic_hot_water_setpoint number to Plugwise (#98092)

* Add max_dhw_temperature number

* Update strings.json

* Add related tests

* Correct test

* Black-fix
This commit is contained in:
Bouwe Westerdijk 2023-08-13 12:57:34 +02:00 committed by GitHub
parent 38cea8f31c
commit b41d3b465c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 40 additions and 1 deletions

View File

@ -48,6 +48,14 @@ NUMBER_TYPES = (
entity_category=EntityCategory.CONFIG,
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
),
PlugwiseNumberEntityDescription(
key="max_dhw_temperature",
translation_key="max_dhw_temperature",
command=lambda api, number, value: api.set_number_setpoint(number, value),
device_class=NumberDeviceClass.TEMPERATURE,
entity_category=EntityCategory.CONFIG,
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
),
)
@ -89,7 +97,6 @@ class PlugwiseNumberEntity(PlugwiseEntity, NumberEntity):
self.entity_description = description
self._attr_unique_id = f"{device_id}-{description.key}"
self._attr_mode = NumberMode.BOX
self._attr_native_max_value = self.device[description.key]["upper_bound"]
self._attr_native_min_value = self.device[description.key]["lower_bound"]
self._attr_native_step = max(self.device[description.key]["resolution"], 0.5)

View File

@ -76,6 +76,9 @@
"number": {
"maximum_boiler_temperature": {
"name": "Maximum boiler temperature setpoint"
},
"max_dhw_temperature": {
"name": "Domestic hot water setpoint"
}
},
"select": {

View File

@ -40,3 +40,32 @@ async def test_anna_max_boiler_temp_change(
mock_smile_anna.set_number_setpoint.assert_called_with(
"maximum_boiler_temperature", 65.0
)
async def test_adam_number_entities(
hass: HomeAssistant, mock_smile_adam_2: MagicMock, init_integration: MockConfigEntry
) -> None:
"""Test creation of a number."""
state = hass.states.get("number.opentherm_domestic_hot_water_setpoint")
assert state
assert float(state.state) == 60.0
async def test_adam_dhw_setpoint_change(
hass: HomeAssistant, mock_smile_adam_2: MagicMock, init_integration: MockConfigEntry
) -> None:
"""Test changing of number entities."""
await hass.services.async_call(
NUMBER_DOMAIN,
SERVICE_SET_VALUE,
{
ATTR_ENTITY_ID: "number.opentherm_domestic_hot_water_setpoint",
ATTR_VALUE: 55,
},
blocking=True,
)
assert mock_smile_adam_2.set_number_setpoint.call_count == 1
mock_smile_adam_2.set_number_setpoint.assert_called_with(
"max_dhw_temperature", 55.0
)