Hello!
Here is my problem. In the script below, I ask to change the state of a button. This command works well (the button changes state). But if I ask to show me this state immediately, the answer is wrong.
Can anyone explain to me? And find me a solution?
Thanks
Because you are using Svalue and that is not used for switches. A switch uses nvalue but better use .state (string) or .active (boolean) to get the state of a switch.
See https://www.domoticz.com/wiki/DzVents:_ ... ll_devices
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Yes, you are right: dzvents needs to be refresh but it can't do it in the same passage. It needs to recall all the script (for instance, next minute if trigger is Timer).
You have to work on your script logic to turn on or off the switch one time.
It makes no sense to turn on/off the switch multiple times in the same script
So make a Boolean, and in the end, if this is true, turn on the switch, and if not, turn it off
Hello gizmocuz
I don't want to change state multiple times. The script I wrote is there to highlight the poor real-time button state display. It is only done once the script is finished and not in real time.
Try this script:
It's by design, as you can see in the script, you 'return' an object
What do you expect? That during a line executed from dzVents the state is updated?
Nope...
So, what you want is not working and should also not be necessary or done.
I understand the design well. It is the same as for LUA (of which dzvents is an application). I'm troubled by the fact that the button's state can change several times in the script but not its representation. Currently I transpose all my lua scripts (>40) into dzvents and I don't always see the benefit of doing so. That said to solve this problem in dzvents, I use the Device trigger.
Thank you for your reply.