SevenW wrote:Although the topic is put to solved, the original issue, preventing update loops is not solved. There is only a work around proposed.
The root problem is that when one is using on / off actions for the virtual switches.
When a virtual switch is operated from the http-json-api, the actions are triggered, but should not (or at least not operate the switch again). When the switch is operated form the domoticz UI, the actions are triggered as well, and should operate the external switch. Operation of the external switch always report its latest state back. This creates a loop.
I Noticed the loop, and tried working with dates and timestamps.
tried to compare MQTT domoticz/out/# output from domoticz and tried to compare that with plugwise/state/circle/#
But the script command was in the way on updating the device status.
I had no quick results. So I left it the way it is right now.
SevenW wrote:The loop can be stopped in different ways:
- Block On/Off actions for a number of seconds after switching with an json command with param=udevice&nvalue=0|1
- Know the source of the switching, pass it with the action and prevent forwarding the action to the external device if that was the party who has sent the switch command.
- Another right way could be that a MQTT/API able status update is implemented and is separated from the switch command if needed. I think that that would give much more power to Domoticz. Switching can be done via MQTT in Domoticz. (
https://www.domoticz.com/wiki/MQTT#Send ... ch_Command)
- Maybe plugwise can be made hybrid and more Domoticz capable and read/write into the domoticz MQTT tree... (dunno if that is possible )
- Why not a new api option that just updates the status but not execute the command.
param=udevice&nvalue=[0|1]&execscript=[0|1]
By default the execscript is 1, this way nothing changes in API behavior.
As I look at it, this is a problem in Domoticz.
I see another example that might go wrong.... KAKU for instance. You don't know the state of the product, you just fire commands at it and hope the receiver really receives the command. With the execscript you can update the status of the KAKU device if you can read the device (maybe a webcam) it switches.
Another thing (that personnaly annoyed me).... Adding the virtual switches or sensors via, in our case, NodeRed. We create devices with a sensible and for us a reproducible ID. Now we cannot switch with that ID via the API. When looking at it from NodeRed we need the unknown internal idx value to switch. Of course I can find out what the value of the idx is via our ID... but hey, looking up an ID/idx combo, create a translate table and use that translate table to switch the correct idx number. Why can't I use the ID directly in the API?
And another thing.... Why can't I create virtual switches and sensors with the same ID and use unit number 1 for the switch and use unit number 2 for the readout of the power?
SevenW wrote:The first version can be implemented in lua script or node-red (as proposed earlier), but has a downside: In the dead-time (after a udevice update of the switch state) any domoticz user interface action will switch domoticz, but does not tell the external party: Result is inconsistency between domoticz and external device.
You are pushing for a concession. I would go for a right solution into Domoticz. If I would have the programming skills, I would be very glad in doing that. But I only master shell scripting.
SevenW wrote:So the preferred solution is to add a switcher-uid or something like that to the post-action, so that if the post action calls node-red, targeted blocking of messages can happen. I think adding a switcher-uid is a better solution than conditionally prevent the post-action. There may be many other uses of the post-actions. (On / Off actions).
Is it worthwhile submitting this as a change request?
SevenW
As I interpret/read it... I think it is too complicated and would not be reusable for other projects.
You have written a very cool program with plugwise2py but Domoticz does not play nice with it. I really like the scheduling tool in it, but is incompatible with Domoticz in every way. I removed all plugwise2py schedules from the circles and am forced to use the _crappy_ (NFI) schedules in Domoticz. Just to get updated statuses. I use a extensive schedule for my floor heating and that switches on and off every quarter and changes by weekdays and weekends. Now I have a 40line schedule in Domoticz.
Would it very hard for Rob to implement the pluswise code ( automagically transformed to the C language ) natively into Domoticz? This way plugwise would behave more like the Fibaro wallsockets which perform very nice in Domoticz. I would lend him a Plugwise set if needed for testing.
I hope I gave you some more and/or better ideas to work with.
Of course these are my 2 cents for tonight ...