Smanar / Domoticz-deCONZ

deCONZ plugin for Domoticz (Zigbee application)
GNU General Public License v3.0
36 stars 26 forks source link

Tiny bug for windows blinds #112

Closed RDols closed 1 year ago

RDols commented 2 years ago

I think in fonctions.py line 448 the next line should be changed:

if val == 'True': to if val == 'true':

as for a i known, boolean string are always fully lower case, at least in my deconz.

If you want i can change it and create an pull request, but will take a few days

Regards, Richard

RDols commented 2 years ago

Note, there are a few more 'True' with i think in wrong casing.

Smanar commented 2 years ago

I don't think Because in python bolean are not fully lower case, It 's True and False

a = (5 == 5)
print(a)

Result True

In deconz boolean are lower case, so they are lower in the json too, but when the python core use them the case is changing.

You can try a print (val) to be sure.

RDols commented 2 years ago

Yup you are absolutly right. I assumed the string was directly from json. But actually it's string representation of the a python boolean.

But the reason i looking is because my ikea blinds don't give (correct) updates, see them in the websocket events. But it updates wrong. Still debugging, but i think is because the response has multiple values.

On the websocket i find this as position update: {'e': 'changed', 'id': '18', 'r': 'lights', 'state': {'bri': 226, 'lift': 89, 'on': True, 'open': True, 'reachable': True}, 't': 'event', 'uniqueid': '00:0d:6f:ff:fe:aa:48:4b-01'}

The final kwarg is: {'nValue': 1, 'sValue': 'Open'}

It appears ProcessAllState will handle the next values, in the this particular order: 'on' 'bri' 'open'

Looking at deconz api 'bri' is deprecated and 'lift' should be used. My suggeston would be to move the if 'bri' down in the if structure and also add a if 'lift'.

I'm still debugging, so maybe i missed something and could be wrong....

RDols commented 2 years ago

I'm testing the above commits....

Smanar commented 2 years ago

But I don't understand the problem

The final kwarg is: {'nValue': 1, 'sValue': 'Open'}

And it s not good ? If lift = 89, it mean the VR is open, nope ?

RDols commented 2 years ago

If you look at if fully binary, yes. But I set it up as switch type "Blinds Percentage". Which give you a range for 0%-100% to read and set the blind. Open translates to 0% and Closed to 100%. Otherway 100% translates to closed and < 100% translates to open.

If i set my blinds to e.g. 50%, it says it's fully open instead of halfway.

The domoticz phython api says for reporting blinds: Closed: nValue = 1 and sValue = 100 partially opened: nValue = 2 and sValue = 1-99 Open: nValue = 0 and sValue = 0

The lift value of deconz: Supported range is 0–100 or special value "stop". lift is best understood as “percentage closed”. So for any lift value below 100 %, open is true. 0–99 — open is true 100 — open is false "stop" — Stops the lift action

RDols commented 2 years ago

I your example I would like to report to Domoticz it's opened 89% instead it's open. Then it is correctly displayed.

Smanar commented 2 years ago

ATM the pthon code use

    if command == 'bri':
        #kwarg['nValue'] = 1
        val = int(int(val) * 100 / 255 )
        if model == 'Window covering device':
            if val < 2:
                kwarg['sValue'] = '0'
                kwarg['nValue'] = 0
            elif val > 99:
                kwarg['sValue'] = '100'
                kwarg['nValue'] = 1
            else:
                kwarg['sValue'] = str(val)
                kwarg['nValue'] = 17
        else:
            kwarg['sValue'] = str(val)

So if lift = 89 (or bri = 226) you will have partially opened no ? With nValue = 17 and sValue = 89 In your exemple you have used 2 and me 17, I don't remember what is the difference.

Edit: I think I have found the problem, it s "open" used for other device Try to put "open" before "bri"

Smanar commented 2 years ago

@RDols So it s still not better with that ?

RDols commented 2 years ago

@Smanar I missed you edit. but thats correct, it handles "open" after "bri" so it overwrites values found with "bri". In my commit 22493f1 is changed the order, and also added handling of "lift".

To be honnest, the nValue 17 i don't know what is does, according the manual it should be 2, so i changed it blindly. My deconz has "lift" so this handler will be overwritten anyway.

RDols commented 2 years ago

I tested the code last week. Changes in commit 22493f1 work well.

But the changes in my second commit 2e79be4 unfortianatly don't sove the problem. The blinds still stop after 1 or 2 seconds most of the time. Still looking into this.

Smanar commented 2 years ago

I don't remember, from my memory, it was from the icon displayed on the widget. I have used different value up to find a good one, and "2" was not the better, I was searching an icon with a semi-closed covering (or perhaps a "stop" icon) It's possible it have changed now, if you don't see difference with 17 or 2 ?

But the changes in my second commit 2e79be4 unfortianatly don't sove the problem

What is your second issue ? You can use only "lift" or "bri" in the request "on" and "open" are not mandatory. You set for exemple 90% and the covering stop before 90% after 1/2 s ? How are you setting the value ? If you enable log, you can see if it's from deconz or domoticz. Can come from the device too, because I realy don't have return with this kind of problem for covering.

RDols commented 2 years ago

Second issue is when i open the blind, it sometimes stops after short time. Most of the time it works. It's set from dzVents scripts, with just the open command. I'm not sure where it comes from. domoticz, dzVents scripts, plugin or deCONZ itself. Every time it sit down to dive into this it works, when just want to use it, it stops, typically an Heisenbug...

RDols commented 2 years ago

Having a different nValue should not give a different icon, but could influance the status text. I will check in code what it does. I didn't test what the difference values result to.

RDols commented 2 years ago

Setting nValue to 17 (gswitch_sStop) will display "Stop" or "Stopped" as status TEXT. Setting nValue to 2 (gswitch_sSetLevel) set the status text "Set Level: %d %%", or "Open" What is displayed is depending on the switch type.

This make some sense when using "Venetian Blinds" as switch type and using the default configuration of deCONZ. Then it will update not that often, and you can see the blinds have stopped somewhere halfway, instead

But I also think it's better to use "Blinds Percentage" type for (Ikea) blinds. You can actual see how far the blinds are closed. Together with the right settings withing deCONZ you can also see the blind opening/closing at the sensor status.

RDols commented 2 years ago

For future reference, how do i configure deCONZ and blinds so they update when moving:

  1. Add the device or just simply re-add them again (without deleting) so the blind is fully reset.
  2. Bind the blind reporting Link to github

If this doesn't work immediatly, disconnect the battery of the blind for 10 seconds. It took me a few attemps to get it working for all blinds....

Smanar commented 2 years ago

Ha yes was for that, I don't remember all the story, but it was asked to have visualy the 3 states : open / close / stop. With this mode you have the 3 states, but not the level ? But seriously I can't say what is the better one ....

Second issue is when i open the blind, it sometimes stops after short time

Try with enabling log, you will be able to see all requests made by domoticz. But if you are using Dzevent few chance it was from domoticz, and can come from the device too.

Smanar commented 2 years ago

@RDols Hello, somes news about your issue ? Do you want to make a PR to change the order for "open" ? or do you want I make it ?

For the nValue, idk what is better, long time ago, somes users have asked for "stop" icon.

Setting nValue to 2 (gswitch_sSetLevel) set the status text "Set Level: %d %%", or "Open"

there is not the slide bar to see the level status ?

RDols commented 2 years ago

@Smanar I finally had some time to sit down to find the problem with the blinds topping. Problem is not in the plugin, but in domoticz zwave. I have a ZRC90 switch, with a long press is open the curtains, but for some reason it sends this notification more than once, making the curtain stop.

RDols commented 2 years ago

For the change of order and nValue i will create a pull request. I strongly suggest for users to use the "Blinds Percentage" type for the curtains. Also tweak the settings according my comment above (https://github.com/Smanar/Domoticz-deCONZ/issues/112#issuecomment-951268071)

Smanar commented 2 years ago

Thx, have put a comment about the branch. Most of covering support only on/off not the Percentage, and there is no way to detect if the device can support them using the actual JSON, I think it will be possible later, with the next deconz feature, the DDF file, we will have a config file by device, so will be possible to remove bri/lift if the device don't use them, and the plugin will be able to create a different widget.

RDols commented 2 years ago

Moved the PR to the beta branch. Will try if i can find a way to get the "stopped" back for these cases.