Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@etienne678
Copy link
Contributor

Add support for Zigbee Smart Water Valve (SWV-BSP)
This PR adds support for the Zigbee Smart Water Valve (SWV-BSP) device, as requested in issue #645.

Implementation Details
Added UIID 7027 support in constants.js
Implemented basic switch functionality in zigbee-water-valve.js
Device works through Sonoff Zigbee Pro Bridge
Device Information
Device logs showing the data structure:

{
"bindInfos": {},
"subDevId": "b95a33feff1227847027",
"parentid": "10023e03d6",
"fwVersion": "1.0.2",
"battery": 100,
"trigTime": "1739203803000",
"supportPowConfig": 1,
"subDevRssi": -3,
"exceptionReport": [],
"hasException": false,
"switch": false,
"realIrrigationVolume": 0,
"realIrrigationVolumeGal": 0,
"todayWaterUsage": 0,
"todayWaterUsageGal": 0,
"controlMode": "manual",
"runningMode": 2
}
Functionality
✅ Basic on/off control from HomeKit
✅ State updates from eWeLink app reflected in HomeKit
✅ Multiple devices tested and working
Future Improvements
While this PR implements basic on/off functionality, the device has additional features that could be added in the future:

Water usage tracking
Irrigation volume monitoring
Battery level reporting
Testing
Tested with multiple SWV-BSP devices connected through a Sonoff Zigbee Pro Bridge. All devices are properly recognized and can be controlled through both HomeKit and the eWeLink app.

@etienne678 etienne678 force-pushed the feature/zigbee-water-valve branch 4 times, most recently from a0a46cd to f222d32 Compare February 12, 2025 05:56
@etienne678 etienne678 force-pushed the feature/zigbee-water-valve branch from f222d32 to 3dc9331 Compare February 12, 2025 06:23
@bwp91
Copy link
Collaborator

bwp91 commented Feb 12, 2025

Hi @etienne678

Thanks for taking the time to make this PR.

Question: any reason why you chose a switch accessory rather than a homekit water valve accessory?

@etienne678
Copy link
Contributor Author

etienne678 commented Feb 12, 2025

Hi @etienne678

Thanks for taking the time to make this PR.

Question: any reason why you chose a switch accessory rather than a homekit water valve accessory?

Hi @bwp91 ,
no reason, just thought of the simplest way an went with a switch.
I wasn’t aware that homekit water valve accessory is available.
But I think I yes, it would be much better as water valve accessory.

@bwp91
Copy link
Collaborator

bwp91 commented Feb 12, 2025

Here is an example:

this.service = this.accessory.getService(this.hapServ.Valve)
if (!this.service) {
this.service = this.accessory.addService(this.hapServ.Valve)
this.service.updateCharacteristic(this.hapChar.Active, 0)
this.service.updateCharacteristic(this.hapChar.InUse, 0)
this.service.updateCharacteristic(this.hapChar.ValveType, 1)
this.service.updateCharacteristic(this.hapChar.SetDuration, 120)
this.service.addCharacteristic(this.hapChar.RemainingDuration)
}

  • You can use Valve instead of Switch
  • Instead of hapChar.On use hapChar.Active (with 1 and 0 instead of true and false)
  • Also use hapChar.InUse with 1 and 0 and keep this value the same as hapChar.Active at all times
  • Set hapChar.ValveType to 1 when initially creating the service (it never needs updating again)

Etienne Doussin added 2 commits February 12, 2025 10:58
This commit refactors the Zigbee Smart Water Valve (SWV-BSP) implementation to use the HomeKit Valve service instead of the Switch service.

This change provides a more semantically accurate and feature-rich representation of the water valve in HomeKit, including:

-   **Valve Service**:  Switched from Switch to the more appropriate Valve service.
-   **Valve Characteristics**: Implemented support for key Valve characteristics:
    -   `Active`: For on/off control.
    -   `InUse`: To indicate active watering.
    -   `ValveType`: Set to Irrigation (1).
    -   `SetDuration`: To configure watering duration.
    -   `RemainingDuration`: To display remaining watering time.
-   **Timer Functionality**: Added automatic valve shut-off after the set duration, enhancing irrigation control.
-   **State Management**:  Maintained robust state caching and error handling from previous Switch implementation.

This update provides an improved user experience for controlling Zigbee Smart Water Valves within HomeKit, aligning with the intended functionality of a valve accessory.
@etienne678
Copy link
Contributor Author

@bwp91 the Valve device does not appear in the automation section in the home app.
can you see why? when i use the switch solution it does show up.

@bwp91
Copy link
Collaborator

bwp91 commented Feb 15, 2025

@bwp91 the Valve device does not appear in the automation section in the home app. can you see why? when i use the switch solution it does show up.

did you manage to sort this at all?

@etienne678
Copy link
Contributor Author

etienne678 commented Feb 15, 2025 via email

@bwp91
Copy link
Collaborator

bwp91 commented Feb 15, 2025

You can use the Eve for HomeKit app to create scenes for valves

@etienne678
Copy link
Contributor Author

ooh, ok, then Valve isn't even supposed to be available for automations within the apple home app? that would explain a lot. i tried everything to make it appear there and finally gave up when it just would not work.
but yes, i can see it in the eve app. well ok, then i think it works as good as it can as Valve type.

on antother note, I tried to display other values for the default run time for the irrigation in the apple home app, because i think for irrigation valves it would be good if the user could set the duration in smaller increments as well.

IMG_36282FF5ADB2-1

i tried with something like this:
´´´
this.service.getCharacteristic(this.hapChar.SetDuration)
.setProps({
validValues: [10, 20, 30, 60, 120, 300, 600, 900, 1800, 3600] // Explicit durations
})
.updateValue(60); // Default duration

´´´
did not work.

@bwp91
Copy link
Collaborator

bwp91 commented Feb 16, 2025

I think these are a set list for all valve types, whether the accessory is native to homekit as a valve, or via homebridge.

If using a valid values array did not work, then I would not know what else to suggest.

Are you happy with this PR as it is?

@etienne678
Copy link
Contributor Author

etienne678 commented Feb 16, 2025

ok, thanks.

Are you happy with this PR as it is?

I have my garden irrigation with 4 of these Valves now working for 2 days with the changes in this PR. i currently run commit e4363e5. i tested a lot and so far it all works fine.
It's a pity that Valves cannot be automated through the Home app directly, but apparently we cannot change this. So I'd say it is good to go from my side.

But: I never coded a device for homebridge before and running water is involved, so i would be very happy if you could check to make sure it is done correctly before this sets someones house under water :D

@bwp91 bwp91 merged commit 3dec172 into homebridge-plugins:latest Feb 24, 2025
4 checks passed
@bwp91
Copy link
Collaborator

bwp91 commented Feb 24, 2025

thank you for taking the time to do this!

@etienne678
Copy link
Contributor Author

thank you for taking the time to do this!

no problem. thank you for the plugin, it is great.

@etienne678 etienne678 deleted the feature/zigbee-water-valve branch February 24, 2025 07:52
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