Skip to content

Commit

Permalink
Test duplicate setting
Browse files Browse the repository at this point in the history
    * custom_components/daikin_onecta/climate.py:
    * tests/test_init.py:
  • Loading branch information
jwillemsen committed Nov 28, 2024
1 parent acb1f6c commit c9e130e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
2 changes: 2 additions & 0 deletions custom_components/daikin_onecta/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,7 @@ async def __set_swing(self, direction, swing_mode):
return res

async def async_set_swing_mode(self, swing_mode):
res = True
if self.swing_mode != swing_mode:
res = await self.__set_swing("vertical", swing_mode)

Expand All @@ -665,6 +666,7 @@ async def async_set_swing_mode(self, swing_mode):
return res

async def async_set_swing_horizontal_mode(self, swing_mode):
res = True
if self.swing_horizontal_mode != swing_mode:
res = await self.__set_swing("horizontal", swing_mode)

Expand Down
20 changes: 20 additions & 0 deletions tests/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -836,6 +836,26 @@ async def test_climate(
assert hass.states.get("climate.werkkamer_room_temperature").attributes["swing_horizontal_mode"] == "swing"
assert hass.states.get("climate.werkkamer_room_temperature").attributes["swing_mode"] == "swing"

# Set the horizontal swing mode another time to swing, should not result in a call
await hass.services.async_call(
CLIMATE_DOMAIN,
SERVICE_SET_SWING_HORIZONTAL_MODE,
{ATTR_ENTITY_ID: "climate.werkkamer_room_temperature", ATTR_SWING_HORIZONTAL_MODE: "swing"},
blocking=True,
)
await hass.async_block_till_done()

# Set the vertical swing mode another time to swing, should not result in a call
await hass.services.async_call(
CLIMATE_DOMAIN,
SERVICE_SET_SWING_MODE,
{ATTR_ENTITY_ID: "climate.werkkamer_room_temperature", ATTR_SWING_MODE: "swing"},
blocking=True,
)
await hass.async_block_till_done()

assert len(responses.calls) == 15

# Set the preset mode boost
await hass.services.async_call(
CLIMATE_DOMAIN,
Expand Down

0 comments on commit c9e130e

Please sign in to comment.