Skip to content

Commit c517b78

Browse files
committed
Revert "Use water_sense_mode device API for smart program on/off"
This reverts commit 54a14d6.
1 parent 54a14d6 commit c517b78

3 files changed

Lines changed: 14 additions & 40 deletions

File tree

custom_components/bhyve/pybhyve/client.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -249,13 +249,6 @@ async def update_program(self, program_id: str, program: BHyveTimerProgram) -> N
249249
json = {"sprinkler_timer_program": program}
250250
await self._request("put", path, json=json)
251251

252-
async def update_device(self, device: dict) -> None:
253-
"""Update device settings."""
254-
device_id = device.get("id")
255-
path = f"{DEVICES_PATH}/{device_id}"
256-
json = {"device": device}
257-
await self._request("put", path, json=json)
258-
259252
async def send_message(self, payload: Any) -> None:
260253
"""Send a message via the websocket."""
261254
if self._websocket is not None:

custom_components/bhyve/switch.py

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -217,35 +217,17 @@ def is_on(self) -> bool:
217217

218218
async def async_turn_on(self, **_kwargs: Any) -> None:
219219
"""Turn the switch on."""
220-
if self.program_data.get("is_smart_program"):
221-
await self.coordinator.client.update_device(
222-
{
223-
"id": self._device_id,
224-
"type": self._device_type,
225-
"mac_address": self._mac_address,
226-
"water_sense_mode": "auto",
227-
}
228-
)
229-
else:
230-
program = BHyveTimerProgram(self.program_data)
231-
program["enabled"] = True
232-
await self.coordinator.client.update_program(self._program_id, program)
220+
program = BHyveTimerProgram(self.program_data)
221+
program["enabled"] = True
222+
await self.coordinator.client.update_program(self._program_id, program)
223+
# Coordinator updates via WebSocket event
233224

234225
async def async_turn_off(self, **_kwargs: Any) -> None:
235226
"""Turn the switch off."""
236-
if self.program_data.get("is_smart_program"):
237-
await self.coordinator.client.update_device(
238-
{
239-
"id": self._device_id,
240-
"type": self._device_type,
241-
"mac_address": self._mac_address,
242-
"water_sense_mode": "off",
243-
}
244-
)
245-
else:
246-
program = BHyveTimerProgram(self.program_data)
247-
program["enabled"] = False
248-
await self.coordinator.client.update_program(self._program_id, program)
227+
program = BHyveTimerProgram(self.program_data)
228+
program["enabled"] = False
229+
await self.coordinator.client.update_program(self._program_id, program)
230+
# Coordinator updates via WebSocket event
249231

250232
async def start_program(self) -> None:
251233
"""Begins running a program."""

tests/test_switch.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ def create_mock_coordinator(devices: dict, programs: dict) -> MagicMock:
3737
coordinator.client = MagicMock()
3838
coordinator.client.send_message = AsyncMock()
3939
coordinator.client.update_program = AsyncMock()
40-
coordinator.client.update_device = AsyncMock()
4140
return coordinator
4241

4342

@@ -413,14 +412,14 @@ async def test_program_switch_turn_on(
413412
description=description,
414413
)
415414

416-
# Turn on the switch (smart program uses update_device)
415+
# Turn on the switch
417416
await switch.async_turn_on()
418417

419-
# Verify update_device was called with water_sense_mode=auto
420-
coordinator.client.update_device.assert_called_once()
421-
call_args = coordinator.client.update_device.call_args[0][0]
422-
assert call_args["id"] == TEST_DEVICE_ID
423-
assert call_args["water_sense_mode"] == "auto"
418+
# Verify update_program was called with enabled=True
419+
coordinator.client.update_program.assert_called_once()
420+
call_args = coordinator.client.update_program.call_args[0]
421+
assert call_args[0] == TEST_PROGRAM_ID
422+
assert call_args[1]["enabled"] is True
424423

425424
async def test_program_switch_turn_off(
426425
self,

0 commit comments

Comments
 (0)