Gladys
Gladys copied to clipboard
ZwaveJS-UI: Add support for multilevel switch
Pull Request check-list
To ensure your Pull Request can be accepted as fast as possible, make sure to review and check all of these items:
- [x] If your changes affects code, did your write the tests?
- [x] Are tests passing? (
npm test
on both front/server) - [x] Is the linter passing? (
npm run eslint
on both front/server) - [x] Did you run prettier? (
npm run prettier
on both front/server) - [ ] If you are adding a new features/services, did you run integration comparator? (
npm run compare-translations
on front) - [x] Did you test this pull request in real life? With real devices? If this development is a big feature or a new service, we recommend that you provide a Docker image to the community (french forum/english forum) for testing before merging.
- [ ] If your changes modify the API (REST or Node.js), did you modify the API documentation? (Documentation is based on comments in code)
- [ ] If you are adding a new features/services which needs explanation, did you modify the user documentation? See the GitHub repo and the website.
- [ ] Did you add fake requests data for the demo mode (
front/src/config/demo.js
) so that the demo website is working without a backend? (if needed) See https://demo.gladysassistant.com.
NOTE: these things are not required to open a PR and can be done afterwards / while the PR is open.
Description of change
Add support for multilevel switch
Codecov Report
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 98.39%. Comparing base (
9d50528
) to head (13bd988
). Report is 23 commits behind head on master.
Additional details and impacted files
@@ Coverage Diff @@
## master #2038 +/- ##
=======================================
Coverage 98.38% 98.39%
=======================================
Files 844 846 +2
Lines 13743 13805 +62
=======================================
+ Hits 13521 13583 +62
Misses 222 222
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Job #2481: Bundle Size — 10.07MiB (~+0.01%).
13bd988(current) vs e4c0f82 master#2480(baseline)
[!WARNING] Bundle contains 3 duplicate packages – View duplicate packages
Bundle metrics
2 changes
1 regression
Current Job #2481 |
Baseline Job #2480 |
|
---|---|---|
5.39MiB (~+0.01% ) |
5.39MiB |
|
303.21KiB |
303.21KiB |
|
53.43% |
0% |
|
51 |
51 |
|
170 |
170 |
|
1465 |
1465 |
|
21 |
21 |
|
0.82% |
0.82% |
|
124 |
124 |
|
3 |
3 |
Bundle size by type
1 change
1 regression
Current Job #2481 |
Baseline Job #2480 |
|
---|---|---|
7.17MiB (~+0.01% ) |
7.17MiB |
|
2.46MiB |
2.46MiB |
|
319.99KiB |
319.99KiB |
|
93.55KiB |
93.55KiB |
|
17.53KiB |
17.53KiB |
|
13.58KiB |
13.58KiB |
View job #2481 report View MathieuAndrade:master branch activity View project dashboard
I have device with the same feature multilevel switch but in my case it's not a lighting ! So are you sure this is the good category? For example my devices are used to drive electrical heater and shutter.
Which category should we use instead? Gladys doesn't have a "generic" category for this device type that you can use in various cases, and the service doesn't seem designed to manually set the device type either. 🤔
I also started working on the integration and chose the switch.dimmer type. I think it's the most 'generic' type you can use? What do you think? Because I don't want to see my shutters or heaters as lights
@MathieuAndrade Thanks for the PR 🙌
Indeed, is there any way in ZwaveJS UI MQTT payloads to differentiate devices? How do you know if it's a light or a rolling shutter?
Hello !
@William-De71 If this category works as same as LIGHT.BRIGHTNESS why not, if i have time this week a tried to check this.
@Pierre-Gilles There is no difference for ZwaveJSUI, a multilevel is a multilevel, you can plug in a light, a rolling shutter, a fan, a motor or anything that works with power variation. The must would be to let the user tell to gladys what kind of device is plugged.
PS: Sorry for the late response
@MathieuAndrade , Maybe my solution isn't the best solution, but in my opinion it's the most generic feature in Gladys that could work.
@Pierre-Gilles , @MathieuAndrade is right, a multilevel is a multilevel, in my case the only way to differentiate devices is to read the "productDescription"
Below an example of my shutter and one of my heater:
@MathieuAndrade @William-De71
There is no difference for ZwaveJSUI
Shit, sure there is no way? It'll pose issues for basic lights, if they are detected as power plugs, it'll be really annoying in Gladys... Same for rolling shutters...
We need to find a way, even if it's a hacky one.
@William-De71 I have switched to SWITCH.DIMMER and it works as expected, i can push it if is good for @Pierre-Gilles
@Pierre-Gilles If you want, you can read product information (manufacturer, id, description and type) to know what type device is, but this adds a useless complexity in my opinion. And like I said above, the user can plugin anything that works with power management on this type of Zwave device so it won't work in many cases,
For exemple: A multilevel roller shutter, A multilevel RGBW controller, A multilevel dimmer
If you read the device's description:
- for rolling shutter ->
The device allows for controlling motors of roller blinds, awnings, venetian blinds, gates and others, which are single phase AC powered.
- for RGBW controller ->
Fibaro RGBW Controller uses PWM output signal, which enables it to control LED, RGB, RGBW strips, halogen lights and fans.
- for dimmer ->
Dimmer 2 remotely controlled light dimming module is designed to work with various types of light sources.
So :
- for rolling shutter: You can control anything that works with a motor.
- for RGBW controller: You can control any led strip but also a simple light or a fan (fun fact it can be used to read sensors data also 😂)
- for dimmer: This is the only Zwave device that you can be sure has a simple light plugged in.
These examples are only for Fibaro devices, but all Zwave devices are not same, and all manufacturer can implement functionalities differently in his device. So, there is no real method to know how a user use his Zwave device, otherwise, ZwaveJS would have already implemented it. :information_desk_person:
In my opinion, the generic type proposed by @William-De71 (SWITCH.DIMMER) is the best solution until the user can manualy tell to Gladys what kind of device is plugged on his Zwave device.
@MathieuAndrade Ok let's do it then :)
Hello,
I also worked on the Multilevel Switch integration. Unfortunatelly, I saw your PR only when I first started to push my integration on Github. PR is available here.
There is no difference for ZwaveJSUI, a multilevel is a multilevel, you can plug in a light, a rolling shutter, a fan, a motor or anything that works with power variation. The must would be to let the user tell to gladys what kind of device is plugged.
You are totally right for a multilevel switch device such as... "classical" switches. But, zWave provides some context about the device class. The property is called deviceClass
. In the case of multilevel switch for curtains, usually, devices let us know they are for managing curtains.
That's one thing handled in my proposition. Thanks to that, we can nativelly map to COVER devices or DIMMER ones. There is no way for dimmers to know if there is a light or anything else at the end. But, for curtains, we can.
Another thing managed in my PR proposition is that one zWave property could be mapped to multiple "Gladys feature". This provide the capacity for dimmers to have two kind of actionners: dimmer (you can set any value from 0 to 99) or binary state ; and for multilevel curtains switch: position (you can set any value from 0 to 99) or managing OPEN|STOP|CLOSE. That way we can provide different ways to interact with the device. Example here:
Let me know what you think about this proposition
Thanks @sescandell for the PR 🙏
I agree with your PR, if there are no feedback from @William-De71 and @MathieuAndrade before Monday 6, I'll deploy your PR :)
Merged in https://github.com/GladysAssistant/Gladys/pull/2061