Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Device Support Request] Sonoff SWV-BSP Smart Water Valve #3298

Open
andy-81 opened this issue Aug 11, 2024 · 23 comments
Open

[Device Support Request] Sonoff SWV-BSP Smart Water Valve #3298

andy-81 opened this issue Aug 11, 2024 · 23 comments

Comments

@andy-81
Copy link

andy-81 commented Aug 11, 2024

Problem description

Currently only opening and closing the valve is possible however the Sonoff hub and Zigbee2MQTT support pulling in if there is an issue with the valve and the flow data from the valve which would be fantastic to be able to use in ZHA.

Solution description

It would be great if a custom quirk could be created however I have struggled to follow along with the details of how to create the custom device handlers. I was hoping the work from Z2M may help point to how to pull the information but the information does not look similar to the Zwave standard where you require the address details which has further complicated me understanding how to write the custom driver. Any help in someone creating this custom handler would be appreciated.

Screenshots/Video

Screenshots/Video

https://youtu.be/ofzIoxliNJo?si=9JpD2oPFi9j76muC

this video shows the details of what is shown in ZHA vs what is shown in Zigbee2MQTT

Device signature

Device signature
[Paste the device signature here]

Diagnostic information

Diagnostic information
[Paste the diagnostic information here]

Logs

Logs
[Paste the logs here]

Custom quirk

Custom quirk
[Paste your custom quirk here]

Additional information

No response

@AKTheKnight
Copy link

Just got one of these and can provide some of the info missing above:

Signature:

{
  "node_descriptor": {
    "logical_type": 2,
    "complex_descriptor_available": 0,
    "user_descriptor_available": 0,
    "reserved": 0,
    "aps_flags": 0,
    "frequency_band": 8,
    "mac_capability_flags": 128,
    "manufacturer_code": 4742,
    "maximum_buffer_size": 82,
    "maximum_incoming_transfer_size": 255,
    "server_mask": 11264,
    "maximum_outgoing_transfer_size": 255,
    "descriptor_capability_field": 0
  },
  "endpoints": {
    "1": {
      "profile_id": "0x0104",
      "device_type": "0x0002",
      "input_clusters": [
        "0x0000",
        "0x0001",
        "0x0003",
        "0x0006",
        "0x0020",
        "0x0404",
        "0x0b05",
        "0xfc11",
        "0xfc57"
      ],
      "output_clusters": [
        "0x000a",
        "0x0019"
      ]
    }
  },
  "manufacturer": "SONOFF",
  "model": "SWV",
  "class": "zigpy.device.Device"
}

Diagnostic info attached.
zha-a1c1fa629b838dd9fa7a401ddd69c026-SONOFF SWV-a6d24191ccfc18b346afd34da19b81e7 (1).json

Let me know if there's more info I can provide

@brodock
Copy link

brodock commented Aug 13, 2024

Cluster 0xfc11 seems to be known by zigbee2mqtt project: https://github.com/Koenkk/zigbee-herdsman-converters/blob/master/src/devices/sonoff.ts#L52-L71

@brodock
Copy link

brodock commented Aug 19, 2024

schedule seems to be handled as part of the custom cluster above in the following attribute 0x5008:

the logic to serialize/de-serialize its content can be seen here:
https://github.com/Koenkk/zigbee-herdsman-converters/blob/master/src/devices/sonoff.ts#L297-L370

@andy-81
Copy link
Author

andy-81 commented Aug 22, 2024

I did find reference in the zigbee2mqtt handler about the SWV valve.

It does mention in the list about the water flow and the status which shows if it is leaking, no pressure...

It can be found here:
https://github.com/Koenkk/zigbee-herdsman-converters/blob/master/src/devices/sonoff.ts#L1104-L1138

@jamesshannon
Copy link

jamesshannon commented Aug 23, 2024

This is the CL that added much of the code. Notice that they also had to edit the fromZigbee.ts file to add the msFlowMeasurement... uh... "thing" (I don't know much about zigbee). Not sure if equivalent work would need to be done here.

@soyxan
Copy link

soyxan commented Aug 28, 2024

I am also interested in this device support. I own the device and can provide any information or perform any test if needed. Thanks!

@benbancroft
Copy link

Hi all,

I've just created PR zigpy/zha#187 for zha, which implements at least the flow rate sensor part of this request. I plan to look at implementing a device handler for 0xfc11 cluster features (i.e. issue status) next if I have some time in coming days/weeks, unless somebody else has already made some progress here?

@benbancroft
Copy link

I've just pushed up #3340 and zigpy/zha#189, which implements device quirk and Home Assistant sensors for valve leak status and water supply status. Other than some device weirdness around having to ensure manufacturer_specific is not set on attribute read, this wasn't too bad to add in the end.

This is working nicely for my irrigation setup so far:
Screenshot 2024-08-31 201915

That should hopefully be everything that was initially requested for this request. There are however other features supported in Zigbee2MQTT (scheduling, shutoff timer etc) that probably could be added as a future enhance, which again I might look at if I get some time.

@soyxan
Copy link

soyxan commented Sep 1, 2024

Thanks a lot, that is a good improvement. Now a newbie question, when will this quirck be available in Home Assistant? Can I manually upgrade ZHA or do I have to wait for a new HA release?

On the other hand, regarding the other features available in Zigbee2MQTT like scheduling (timed and quantitative), I think that is quite important to have them available. Rely in HA for scheduling the irrigation maybe is not the best option as any failure will affect our plants wellbeing :) Been able to define and save the schedules in the SWV device will keep the irrigation working even if HA or the Zigbee network is completely dead. I do not have the skills to do it by my own, but I am available for testing as I own the SWV.

@aaronegger
Copy link

Is there any chance to get the amount of water (total liters)? That would be super usefull :D

@jamesshannon
Copy link

My two cents regarding scheduling, specifically turn-on scheduling. The device will be fairly simple (e.g., time of day, though it might have another way to schedule). It definitely won't have sun-based scheduling, forecast-based scheduling, etc. So it's kinda a weird User Experience if it supports some on-device scheduling but not others.

Now... if you're talking about "time / flow limits" then yes, I agree that's super important. When I turn on the faucet (via HA) then I want to be able to send a "turn off in X" parameter as part of the "on" message. That way if something happens to the network then the device still turns off. I'm a little concerned about my plants, but very concerned about my water running for days. The issue could be something as simple as me rebooting HA at the time that my "turn off" automation is supposed to run.

@TeDeVPrime
Copy link

nice! but how do we get updates for the ZHA in Hass? i don't see these options in my list

@TeDeVPrime
Copy link

guys anyone who can tell us how to get the latest updates?

@brodock
Copy link

brodock commented Sep 24, 2024

it seems the related PRs haven't been merged yet

@andy-81
Copy link
Author

andy-81 commented Sep 30, 2024

Any idea when this pr will be merged?

Would be great to gain access to the features @benbancroft added already. 😊

@TeDeVPrime
Copy link

yeah i have been checking with every update but no luck.
i already had a lot of issues with my water valve left open. i really need to be able to use the on-device timer.

i don't know how ZHA works with HASS, but shouldn't it be able to update on it's own?

@TeDeVPrime
Copy link

guys the new version from HASS came up but still my Sonoff Smart Water Valve just shows on / off switch. nothing more.

no i need to do something?

@jamesshannon
Copy link

The pull requests haven't been approved. After they're approved and merged into the production branch then the updated version of zigpy will need to be included in ZHA, and then ZHA will need to be included in HA. In theory, all these things could happen quickly, but they require approval and merging.

@TeDeVPrime
Copy link

i find it crazy that a pull request would need months.
ZHA should be able to be updated on it's own and not as part of HA.
what if we need a hotfix?

we have had two HA releases since this was fixed. now i have to wait for November (if i am lucky) in order to be able to control my watering safely.

two times it has failed me until now and the water left running.

@jamesshannon
Copy link

I can't speak to the approval process. It might have just gotten forgotten about.

I don't know why you're having so many problems. If you have an HA automation set up that turns it on, then waits, then turns it off, you should only get failures if:
a) The zigbee connection is really flaky. But if that's the case then you probably have failed turn-ons, too?
b) HA dies (or gets restarted, etc) during the on time and then the automation doesn't finish to turn it off.

For:
a) I believe that Zigbee has a bi-directional mechanism and includes confirmation, right? In which case you should be able to build a check-and-retry into your automation. Ie, "repeat: turn off. wait 10 seconds. if it's off then exit"

b) You could build a "failsafe off" automation to run, e.g., every 15 minutes and turn the water off. The more frequently it runs and the longer your watering period the more likely you are to have issues with this (ie, you'll turn off while it should still be one). If that's a problem, you could add a datetime helper or something as a second check.

@TeDeVPrime
Copy link

TeDeVPrime commented Oct 9, 2024

i had two failures

1 was because my HASS crashed..... lucky eh?
and 1 was because the device became "unavailable" for whatever reason.

i also have a friend who had this issue with bad signal

so i don't want to be dependent on critical things like that to HASS. since the device supports natively the solution to my problem.... and since it is fixed... i want that hotfix. because to me... this is a hotfix.

so having all these steps for "approval" for something that i should be able to access as beta or early-release..... it's annoying. especially when HASS has update for every single thing.... except ZHA.

@soyxan
Copy link

soyxan commented Oct 9, 2024

First of all, I totally agree with the comments regarding the long waiting till we get the update, but, in addition to that and AFAIK, the PR #3340 only covers basic feedback sensors from the device (flow measurement and leakage status) but no specific commands like "turn on with shutdown timer" as some of you are expecting. Please correct me if I am wrong.

@TeDeVPrime
Copy link

you are correct. i am hoping that someone will soon figure it out. from what i have read, sonoff made it in a way that when you send the turn on command... you can also pass parameters for water flow and time.

the sensors that "exists" at the moment will give me an extra way of checking the system on event changes.
it will also give me notifications as to whether i have running water or not at my house (it's a weekend house, so i am not there every single day).

i like the simplicity of ZHA but man.... Z2M had these features since day one.

i have never gotten to the technical details between these two (ZHA and Z2M). i just found the ZHA easier and faster to use.
Hopefully we will see updates on this device soon

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

No branches or pull requests

8 participants