Skip to content

Add multi-valve support and rain sensor for irrigator (sfkzq)#6

Open
pgrootkop-cmyk wants to merge 1 commit intoDrenso:mainfrom
pgrootkop-cmyk:feature/irrigator-multi-valve-support
Open

Add multi-valve support and rain sensor for irrigator (sfkzq)#6
pgrootkop-cmyk wants to merge 1 commit intoDrenso:mainfrom
pgrootkop-cmyk:feature/irrigator-multi-valve-support

Conversation

@pgrootkop-cmyk
Copy link
Copy Markdown

Summary

  • Add support for multi-valve irrigation controllers (category sfkzq) that report switch_1switch_4 instead of a single switch code. Previously only battery_percentage was exposed during pairing.
  • Add rain_sensor capability using undocumented DP 49, which reports rain state via MQTT in numeric DP format ({"49":"rain"}).
  • Fix MQTT handler to pass numeric DP format through to devices instead of dropping them — Number.isInteger on string keys always returned false, so these data points were silently discarded.

Changes

Irrigator driver:

  • Detect switch_1switch_4 during pairing and map to individual valve on/off capabilities
  • Master on/off toggle when multiple valves are present
  • Backward compatible with single-switch irrigators
  • DP ID → code translation in onTuyaStatus for undocumented data points
  • Flow cards for per-valve actions, conditions, and triggers (EN/NL)
  • Valve naming translations (EN/NL)

MQTT client (TuyaHaClient.ts):

  • Numeric DP format (e.g. {"49":"rain"}) is now passed through as status["49"] = "rain" instead of being dropped. Drivers can then resolve these IDs to named codes.

Device info

Tested on: Intelligent Watering System (product dapc1pcplj7rxlw8, category sfkzq)

status codes: switch_1–switch_4, countdown_1–countdown_4, battery_percentage
undocumented: DP 49 → rain_sensor_state (values: "rain" / "normal")

Test plan

  • All 4 valves toggle correctly via individual and master switch
  • Rain sensor state updates via MQTT when triggered
  • Flow cards (action/condition/trigger) work for individual valves
  • Rain sensor flow cards trigger on state change
  • Single-switch irrigators still work (backward compatibility preserved)
  • Battery percentage still reported

🤖 Generated with Claude Code

Adds support for multi-valve irrigation controllers (category sfkzq)
that report switch_1 through switch_4 instead of a single switch code.
Previously only battery_percentage was picked up during pairing.

Irrigator changes:
- Detect and map switch_1–switch_4 to individual valve capabilities
- Add master on/off toggle when multiple valves are present
- Preserve backward compatibility for single-switch irrigators
- Add rain_sensor capability using undocumented DP 49
- Translate numeric DP IDs to named codes in onTuyaStatus
- Add flow cards for per-valve actions, conditions, and triggers (EN/NL)
- Add valve naming translations (EN/NL)

MQTT fix:
- Pass numeric DP format (e.g. {"49":"rain"}) through to devices instead
  of dropping them. The previous Number.isInteger check on string keys
  always returned false, causing these data points to be logged as
  malformed and discarded.

Tested on a 4-valve Intelligent Watering System (product dapc1pcplj7rxlw8).
All valves switch correctly, master toggle works, rain sensor state
updates via MQTT, and flow cards trigger as expected.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Member

@bobvandevijver bobvandevijver left a comment

Choose a reason for hiding this comment

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

Thank you for your PR, we have added it to our internal backlog for further processing as well. However, note that it cannot be merged as is due to the included datapoint addition.


// Mapping of numeric DP IDs to Tuya codes for devices that report raw DP format via MQTT
export const IRRIGATOR_DP_ID_MAPPING: Record<string, string> = {
'49': 'rain_sensor_state',
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Data point value mappings are device specific and can therefor not be added to this generic driver.

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.

2 participants