Page 1 of 1

can I control device from LUA?

Posted: Monday 16 January 2023 11:51
by manjh
This seems like a simple question, with an obvious answer: yes. :)

But in this case I have a few zigbee devices (Ikea lamps), that show up as "color switch, ww, dimmer" in Domoticz.
I can switch them on/off, and the color selection works OK as well. But the dim level does not work properly: the "outside" slider works OK, but when I open the widget, the vertical slider next to the color selector does not.
Also, controlling the lamps by timed events or in a scene does not work: on/off and color is ok, dim level is not possible.

So, to circumvent this problem, I though about controlling timed events from a LUA script.
Hence the question: can I control color and dim level from a LUA script?

Meanwhile, I am communicating with the plugin author to see if the problem can be solved at the root. But it would be nice to have an alternative for the time being.

Re: can I control device from LUA?

Posted: Monday 16 January 2023 12:38
by waltervl
In dzVents it is possible. I think for some action in dzVents this is done internally by going to API commands executing the device change because Lua is not supporting it.
https://www.domoticz.com/wiki/DzVents:_ ... .2FApplamp

Edit: See also https://www.domoticz.com/wiki/Domoticz_ ... emperature

Re: can I control device from LUA?

Posted: Monday 16 January 2023 14:29
by manjh
Ah, I see. Problem is I have no knowledge of dzVents, and it seems like a steep learningcurve just to circumvent a problem. I'm still hoping for a more permanent solution in the plugin.
Meanwhile, as you say LUA does not support everything. How about using json? Would that work?

Re: can I control device from LUA?

Posted: Monday 16 January 2023 15:40
by gizmocuz
dzVents is not that hard to learn and you can do a lot more with this
When you go to the even editor and add a new event (dzVents) there are some examples

But I would suggest to do all timers in Domoticz

Re: can I control device from LUA?

Posted: Monday 16 January 2023 16:23
by manjh
gizmocuz wrote: Monday 16 January 2023 15:40 dzVents is not that hard to learn and you can do a lot more with this
When you go to the even editor and add a new event (dzVents) there are some examples

But I would suggest to do all timers in Domoticz
Thanks.
About an hour ago I discovered some more info in the problem in Zigbee-for-Domoticz.
I have two Ikea lamps with individual widgets in Domoticz. When I set timers on them, the brightness is not set correctly (color is OK).
But when I put the two lamps into a Zigbee group and set timers on the group widget, everything works OK, including the brightness level.
I hope this provides the plugin author the info he needs to find the root cause..

Re: can I control device from LUA?

Posted: Monday 16 January 2023 18:40
by waltervl
Please keep this topic on topic as zigbee plugin has nothing to do with Lua.

Re: can I control device from LUA?

Posted: Monday 16 January 2023 19:21
by HvdW
gizmocuz wrote: Monday 16 January 2023 15:40 dzVents is not that hard to learn and you can do a lot more with this
Here is a video and here are some examples.

Re: can I control device from LUA?

Posted: Monday 16 January 2023 19:41
by manjh
waltervl wrote: Monday 16 January 2023 18:40 Please keep this topic on topic as zigbee plugin has nothing to do with Lua.
Hmmm... I understand your statement, but in this case donot agree. My original question here was: can I control these devices from LUA. So I think it is very much on topic.
The text that I added was meant to provide some background info, about "why" I would want to control the lamps from LUA.
ANd on a more general note, I think it would be nice if it were possible. I can already switch lights on and off, so why not these lamps?

Re: can I control device from LUA?

Posted: Monday 16 January 2023 20:49
by waltervl
I think the method with Lua would be to use a domoticz api JSON with Lua OpenUrl command array.

Re: can I control device from LUA?

Posted: Monday 16 January 2023 22:24
by jannl
With this call (change the ip) you can see all attributes of al switches

http://192.168.1.2:8080/json.htm?type=devices&plan=0

With that it should be possible to find the correct way to set the dim level.

Re: can I control device from LUA?

Posted: Monday 16 January 2023 23:34
by HvdW
jannl wrote: Monday 16 January 2023 22:24 With this call (change the ip) you can see all attributes of al switches

http://192.168.1.2:8080/json.htm?type=devices&plan=0
:o :P 8-) !!