Send target temp to Shelly TRV in F when needed (#108188)
This commit is contained in:
parent
d2feee86b7
commit
901b7b6278
2 changed files with 38 additions and 0 deletions
|
@ -316,6 +316,21 @@ class BlockSleepingClimate(
|
||||||
"""Set new target temperature."""
|
"""Set new target temperature."""
|
||||||
if (current_temp := kwargs.get(ATTR_TEMPERATURE)) is None:
|
if (current_temp := kwargs.get(ATTR_TEMPERATURE)) is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# Shelly TRV accepts target_t in Fahrenheit or Celsius, but you must
|
||||||
|
# send the units that the device expects
|
||||||
|
if self.block is not None and self.block.channel is not None:
|
||||||
|
therm = self.coordinator.device.settings["thermostats"][
|
||||||
|
int(self.block.channel)
|
||||||
|
]
|
||||||
|
LOGGER.debug("Themostat settings: %s", therm)
|
||||||
|
if therm.get("target_t", {}).get("units", "C") == "F":
|
||||||
|
current_temp = TemperatureConverter.convert(
|
||||||
|
cast(float, current_temp),
|
||||||
|
UnitOfTemperature.CELSIUS,
|
||||||
|
UnitOfTemperature.FAHRENHEIT,
|
||||||
|
)
|
||||||
|
|
||||||
await self.set_state_full_path(target_t_enabled=1, target_t=f"{current_temp}")
|
await self.set_state_full_path(target_t_enabled=1, target_t=f"{current_temp}")
|
||||||
|
|
||||||
async def async_set_hvac_mode(self, hvac_mode: HVACMode) -> None:
|
async def async_set_hvac_mode(self, hvac_mode: HVACMode) -> None:
|
||||||
|
|
|
@ -146,6 +146,29 @@ async def test_climate_set_temperature(
|
||||||
mock_block_device.http_request.assert_called_once_with(
|
mock_block_device.http_request.assert_called_once_with(
|
||||||
"get", "thermostat/0", {"target_t_enabled": 1, "target_t": "23.0"}
|
"get", "thermostat/0", {"target_t_enabled": 1, "target_t": "23.0"}
|
||||||
)
|
)
|
||||||
|
mock_block_device.http_request.reset_mock()
|
||||||
|
|
||||||
|
# Test conversion from C to F
|
||||||
|
monkeypatch.setattr(
|
||||||
|
mock_block_device,
|
||||||
|
"settings",
|
||||||
|
{
|
||||||
|
"thermostats": [
|
||||||
|
{"target_t": {"units": "F"}},
|
||||||
|
]
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
await hass.services.async_call(
|
||||||
|
CLIMATE_DOMAIN,
|
||||||
|
SERVICE_SET_TEMPERATURE,
|
||||||
|
{ATTR_ENTITY_ID: ENTITY_ID, ATTR_TEMPERATURE: 20},
|
||||||
|
blocking=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
mock_block_device.http_request.assert_called_once_with(
|
||||||
|
"get", "thermostat/0", {"target_t_enabled": 1, "target_t": "68.0"}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
async def test_climate_set_preset_mode(
|
async def test_climate_set_preset_mode(
|
||||||
|
|
Loading…
Add table
Reference in a new issue