Add missing step-differentiation for the Plugwise temperature_offset (#100654)

This commit is contained in:
Bouwe Westerdijk 2023-09-21 19:31:53 +02:00 committed by GitHub
parent f973d4cc26
commit 5cf5f5b4cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 2 deletions

View File

@ -114,7 +114,11 @@ class PlugwiseNumberEntity(PlugwiseEntity, NumberEntity):
self._attr_mode = NumberMode.BOX self._attr_mode = NumberMode.BOX
self._attr_native_max_value = self.device[description.key]["upper_bound"] 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_min_value = self.device[description.key]["lower_bound"]
self._attr_native_step = max(self.device[description.key]["resolution"], 0.5)
native_step = self.device[description.key]["resolution"]
if description.key != "temperature_offset":
native_step = max(native_step, 0.5)
self._attr_native_step = native_step
@property @property
def native_value(self) -> float: def native_value(self) -> float:

View File

@ -71,10 +71,22 @@ async def test_adam_dhw_setpoint_change(
) )
async def test_adam_temperature_offset(
hass: HomeAssistant, mock_smile_adam: MagicMock, init_integration: MockConfigEntry
) -> None:
"""Test creation of the temperature_offset number."""
state = hass.states.get("number.zone_thermostat_jessie_temperature_offset")
assert state
assert float(state.state) == 0.0
assert state.attributes.get("min") == -2.0
assert state.attributes.get("max") == 2.0
assert state.attributes.get("step") == 0.1
async def test_adam_temperature_offset_change( async def test_adam_temperature_offset_change(
hass: HomeAssistant, mock_smile_adam: MagicMock, init_integration: MockConfigEntry hass: HomeAssistant, mock_smile_adam: MagicMock, init_integration: MockConfigEntry
) -> None: ) -> None:
"""Test changing of number entities.""" """Test changing of the temperature_offset number."""
await hass.services.async_call( await hass.services.async_call(
NUMBER_DOMAIN, NUMBER_DOMAIN,
SERVICE_SET_VALUE, SERVICE_SET_VALUE,