feat: add water fountain controls - working mode, LED brightness, DND (closes #94)#202
feat: add water fountain controls - working mode, LED brightness, DND (closes #94)#202aavdberg wants to merge 6 commits intoJezza34000:mainfrom
Conversation
Implements issue Jezza34000#94 - adds missing controls for water fountain devices: - Working mode select (Normal/Smart for W4/W5/CTW2, Standard/Intermittent for CTW3) via BLE command using CMD 220 - LED brightness select (Low/Normal/High) via REST API UPDATE_SETTING - Indicator light (LED on/off) switch via REST API UPDATE_SETTING - Do Not Disturb switch using fountain-specific API key (noDisturbingSwitch) The working mode BLE byte sequences are patched into pypetkitapi's FOUNTAIN_COMMAND at integration startup to avoid requiring a pypetkitapi release. CMD 220 data format: [state, mode, op_type=1]. Translations updated in en, nl, and uk with state labels for select entities. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Adds missing control entities for Petkit water fountain devices, enabling users to manage fountain working mode (via BLE) and LED/DND/indicator settings (via REST) from Home Assistant.
Changes:
- Added water-fountain switches for Indicator light and Do not disturb using
UPDATE_SETTINGREST calls. - Added water-fountain selects for Working mode (BLE CMD 220 via
FountainAction) and LED brightness (RESTlampRingBrightness). - Extended translations (en/nl/uk) with state labels for the new select options.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
custom_components/petkit/__init__.py |
Patches pypetkitapi’s FOUNTAIN_COMMAND at startup to add missing working-mode BLE command frames. |
custom_components/petkit/select.py |
Introduces fountain Working mode + LED brightness select entities and BLE mode handler. |
custom_components/petkit/switch.py |
Adds fountain Indicator light + Do not disturb switch entities using REST settings updates. |
custom_components/petkit/translations/en.json |
Adds translated state labels for working mode and LED brightness options. |
custom_components/petkit/translations/nl.json |
Adds translated state labels for working mode and LED brightness options. |
custom_components/petkit/translations/uk.json |
Adds translated state labels for working mode and LED brightness options. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Hassfest validation requires translation keys to be lowercase [a-z0-9-_]+. Changed FOUNTAIN_WORKING_MODE, FOUNTAIN_WORKING_MODE_CTW3 and LED_BRIGHTNESS const values to lowercase. Updated translation state keys in en/nl/uk.json to match. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Hi @aavdberg However, this PR doesn’t follow the current library architecture. It extends a class that should instead be defined and maintained within the library itself, not directly in the integration code. To keep the structure consistent and maintainable, please update your code to align with the library’s architecture. Any new functionality should first be implemented in pyperkitapi before being integrated into Home Assistant. |
… 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>
|
Hi @Jezza34000, Thanks for the feedback! You're absolutely right — the \FOUNTAIN_COMMAND.update()\ patch in _init_.py\ is not the right place for this. I've made the following adjustments:
Note: this PR depends on pypetkitapi PR #56 being merged and a new version released before it can be fully reviewed/merged. |
…192) Define INDICATOR_LIGHT constant to avoid duplicating the literal string three times in switch.py (lines 51, 77, 837). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
for more information, see https://pre-commit.ci
|
Hi @aavdberg |
Jezza34000
left a comment
There was a problem hiding this comment.
For now this PR does not work properly.
With CTW3 new entity in switch and select are not working.
Light cause 404
Working mode did not throw any error but it's not applied on foutain
- Restore battery mode (3) to FOUNTAIN_WORKING_MODE_CTW3 in const.py: Battery mode is a valid CTW3 state reported by the device and must not be removed from the dict. - CTW3 working mode select: battery is shown as current option when the device reports mode 3, but excluded from selectable options (it is a hardware state entered automatically, not user-settable). _handle_fountain_mode now logs a warning if a read-only mode is somehow selected. - Add ignore_types=[CTW3] to WaterFountain Indicator light and Do not disturb switches: lampRingSwitch and noDisturbingSwitch use the updateSettings REST endpoint which returns 404 on CTW3. - Add ignore_types=[CTW3] to LED brightness select: same reason. - Add CTW3 import to switch.py. - Add 'battery' translation to working_mode states in en/nl/uk.json. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
|
I was about to create an issue to report/ask why the Being able to switch between edit: Regardless, thanks so much to all of you for this amazing integration <3 |
|
Hi @aavdberg, |



Summary
Implements missing controls for water fountain devices requested in #94.
New entities
Technical notes
Working mode via BLE
pypetkitapi's FOUNTAIN_COMMAND dict was missing byte sequences for MODE_NORMAL, MODE_SMART, MODE_STANDARD, and MODE_INTERMITTENT. The sequences follow the same CMD 220 frame format as the existing POWER_ON/POWER_OFF entries and are derived from the W5BLEMQTT project:
cmd=220, type=1, data=[state=1, mode_byte, op_type=1]
These are patched into FOUNTAIN_COMMAND at integration startup in init.py until they can be upstreamed to pypetkitapi.
LED brightness / DND / Indicator light
These settings use UPDATE_SETTING with the correct camelCase field names (lampRingBrightness, lampRingSwitch, noDisturbingSwitch). The fountain-specific noDisturbingSwitch replaces the generic disturbMode key used by other device types.
Translations
State labels for the new select entities added to en, nl, and uk.
Follow-up fixes (addressing review feedback)