Skip to content

Commit 143f7df

Browse files
authored
Use aioshelly methods for climate platform (home-assistant#154384)
1 parent 9a28ee5 commit 143f7df

File tree

2 files changed

+5
-13
lines changed

2 files changed

+5
-13
lines changed

homeassistant/components/shelly/climate.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -749,17 +749,13 @@ def hvac_action(self) -> HVACAction:
749749

750750
async def async_set_temperature(self, **kwargs: Any) -> None:
751751
"""Set new target temperature."""
752-
await self.call_rpc(
753-
"Thermostat.SetConfig",
754-
{"config": {"id": self._id, "target_C": kwargs[ATTR_TEMPERATURE]}},
752+
await self.coordinator.device.climate_set_target_temperature(
753+
self._id, kwargs[ATTR_TEMPERATURE]
755754
)
756755

757756
async def async_set_hvac_mode(self, hvac_mode: HVACMode) -> None:
758757
"""Set hvac mode."""
759-
mode = hvac_mode in (HVACMode.COOL, HVACMode.HEAT)
760-
await self.call_rpc(
761-
"Thermostat.SetConfig", {"config": {"id": self._id, "enable": mode}}
762-
)
758+
await self.coordinator.device.climate_set_hvac_mode(self._id, str(hvac_mode))
763759

764760

765761
class RpcBluTrvClimate(ShellyRpcEntity, ClimateEntity):

tests/components/shelly/test_climate.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -665,9 +665,7 @@ async def test_rpc_climate_hvac_mode(
665665
)
666666
mock_rpc_device.mock_update()
667667

668-
mock_rpc_device.call_rpc.assert_called_once_with(
669-
"Thermostat.SetConfig", {"config": {"id": 0, "enable": False}}
670-
)
668+
mock_rpc_device.climate_set_hvac_mode.assert_called_once_with(0, str(HVACMode.OFF))
671669
assert (state := hass.states.get(entity_id))
672670
assert state.state == HVACMode.OFF
673671

@@ -717,9 +715,7 @@ async def test_rpc_climate_set_temperature(
717715
)
718716
mock_rpc_device.mock_update()
719717

720-
mock_rpc_device.call_rpc.assert_called_once_with(
721-
"Thermostat.SetConfig", {"config": {"id": 0, "target_C": 28}}
722-
)
718+
mock_rpc_device.climate_set_target_temperature.assert_called_once_with(0, 28)
723719
assert (state := hass.states.get(entity_id))
724720
assert state.attributes[ATTR_TEMPERATURE] == 28
725721

0 commit comments

Comments
 (0)