Page 1 of 1
Updating other devices from a plugin
Posted: Monday 22 October 2018 13:52
by mvzut
Hi,
Is it correct that, to update the value of a device that is not created by your own plugin, you have to go through the json route rather than using something like "Devices[Unit].Update(nValue=0, sValue="1")? I came from Lua scripting, where you can access a lot of functionality using imported variables like "commandArray" and "otherdevices" etc. But I believe this is not the case for Python, correct? Just to make sure I didn't overlook anything.
Re: Updating other devices from a plugin
Posted: Monday 22 October 2018 17:59
by Logread
This is correct (see Smart Virtual Thermostat for how I implemented a workaround)
Re: Updating other devices from a plugin
Posted: Wednesday 24 October 2018 0:21
by mvzut
Logread wrote: ↑Monday 22 October 2018 17:59
This is correct (see Smart Virtual Thermostat for how I implemented a workaround)
Thanks.
It's actually pretty stupid that this is the only way, it means you have to ask the user for his Domoticz IP:port, username and password. I don't have enough parameters left for that, plus it doesn't appear very smart from the user's point of view: Why would the plugin need to know all of these things just to set a switch?
Re: Updating other devices from a plugin
Posted: Wednesday 24 October 2018 8:05
by Logread
I think your tone is a bit out of place. Not my choice... but see
viewtopic.php?f=65&t=19780&p=153372#p153372 where the author of the plugin framework explains its rationale. Bear in mind that your plugin can always create a switch that domoticz can monitor through the event system (scripts) for subsequent actions.
Re: Updating other devices from a plugin
Posted: Wednesday 24 October 2018 9:36
by mvzut
Ok, sorry if I was misunderstood, with "stupid" I didn't mean to insult anyone. It just feels a bit silly (is that a better word?) that, in order to read or update a device, you have to go the "external" route, whereas the plugins run internally so all variables could be passed directly.
Some background:
I would like my plugin to be able to set a switch depending on the value of some other devices (managed by the plugin). But I now come to realize that giving users the freedom to select one of their existing switches means asking for four additional user parameters (next to the switch name or IDX). I believe this is a bit too complicated for such a small additional (and optional) feature. I think I will just offer the option to let let the plugin create its own switch. People can then add their own slave devices or scripts to this switch.
Anyway, thanks for the clarification, and sorry for my (unintended) tone...