Skip to content

feat: add fountain working mode commands to FOUNTAIN_COMMAND#56

Merged
Jezza34000 merged 1 commit intoJezza34000:mainfrom
aavdberg:feat/fountain-mode-commands
Apr 1, 2026
Merged

feat: add fountain working mode commands to FOUNTAIN_COMMAND#56
Jezza34000 merged 1 commit intoJezza34000:mainfrom
aavdberg:feat/fountain-mode-commands

Conversation

@aavdberg
Copy link
Copy Markdown
Contributor

Summary

\FountainAction\ already defines \MODE_NORMAL, \MODE_SMART, \MODE_STANDARD\ and \MODE_INTERMITTENT, but none of these had a corresponding entry in \FOUNTAIN_COMMAND. This made it impossible to change the working mode of W4/W5/CTW2/CTW3 fountains via \send_ble_command().

Changes

Added four entries to \FOUNTAIN_COMMAND\ in \command.py:

Action Byte sequence Notes
\MODE_NORMAL\ [220, 1, 3, 0, 1, 1, 1]\ W4/W5/CTW2 — Normal mode
\MODE_SMART\ [220, 1, 3, 0, 1, 2, 1]\ W4/W5/CTW2 — Smart mode
\MODE_STANDARD\ [220, 1, 3, 0, 1, 1, 1]\ CTW3 — Standard mode
\MODE_INTERMITTENT\ [220, 1, 3, 0, 1, 2, 1]\ CTW3 — Intermittent mode

Byte format

[cmd=220, type=1, length=3, start_data=0, power=1, mode_byte, op_type=1]\

  • \op_type=1\ = power/mode control (vs \op_type=2\ = pause/continue)
  • mode byte \1\ = Normal/Standard, mode byte \2\ = Smart/Intermittent

This was verified against the BLE protocol used by PetkitW5BLEMQTT and matches the existing POWER_ON/OFF command structure.

This PR is needed to support the water fountain working mode select entity in the Home Assistant integration (homeassistant_petkit PR #202).

Add missing BLE byte sequences for MODE_NORMAL, MODE_SMART,
MODE_STANDARD and MODE_INTERMITTENT to FOUNTAIN_COMMAND.

These actions were already defined in FountainAction but had no
corresponding byte sequence in FOUNTAIN_COMMAND, making it
impossible to change the working mode via send_ble_command().

Byte format: [cmd=220, type=1, length=3, start_data=0, power=1, mode, op_type=1]
- MODE_NORMAL / MODE_STANDARD: mode byte = 1
- MODE_SMART / MODE_INTERMITTENT: mode byte = 2

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 31, 2026 08:26
@aavdberg aavdberg requested a review from Jezza34000 as a code owner March 31, 2026 08:26
aavdberg added a commit to aavdberg/homeassistant_petkit that referenced this pull request Mar 31, 2026
… mode

- Remove FOUNTAIN_COMMAND.update() patch from __init__.py. The working
  mode commands (MODE_NORMAL, MODE_SMART, MODE_STANDARD, MODE_INTERMITTENT)
  are now part of pypetkitapi directly (see Jezza34000/py-petkit-api#56).

- Remove 'battery' (mode 3) from FOUNTAIN_WORKING_MODE_CTW3 and all
  translations. Battery mode is a hardware/power-source state entered
  automatically when running on battery; it cannot be set by the user via
  BLE. Selecting it would silently do nothing. Removed from const.py and
  en/nl/uk translation files.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds missing BLE command mappings so PyPetkit can switch supported fountains between working modes via send_ble_command().

Changes:

  • Added MODE_NORMAL, MODE_SMART, MODE_STANDARD, and MODE_INTERMITTENT entries to FOUNTAIN_COMMAND.
  • Mapped each mode action to its corresponding BLE byte sequence (aligned with existing POWER_ON/OFF structure).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pypetkitapi/command.py
Comment thread pypetkitapi/command.py
@Jezza34000 Jezza34000 merged commit e15bf16 into Jezza34000:main Apr 1, 2026
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants