can I control device from LUA?

Moderator: leecollings

Post Reply
manjh
Posts: 749
Joined: Saturday 27 February 2016 12:49
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: NL
Contact:

can I control device from LUA?

Post 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.
Hans
User avatar
waltervl
Posts: 5904
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: can I control device from LUA?

Post 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
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
manjh
Posts: 749
Joined: Saturday 27 February 2016 12:49
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: NL
Contact:

Re: can I control device from LUA?

Post 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?
Hans
User avatar
gizmocuz
Posts: 2552
Joined: Thursday 11 July 2013 18:59
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Top of the world
Contact:

Re: can I control device from LUA?

Post 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
Quality outlives Quantity!
manjh
Posts: 749
Joined: Saturday 27 February 2016 12:49
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: NL
Contact:

Re: can I control device from LUA?

Post 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..
Hans
User avatar
waltervl
Posts: 5904
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: can I control device from LUA?

Post by waltervl »

Please keep this topic on topic as zigbee plugin has nothing to do with Lua.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
HvdW
Posts: 617
Joined: Sunday 01 November 2015 22:45
Target OS: Raspberry Pi / ODroid
Domoticz version: 2023.2
Location: Twente
Contact:

Re: can I control device from LUA?

Post 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.
Bugs bug me.
manjh
Posts: 749
Joined: Saturday 27 February 2016 12:49
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: NL
Contact:

Re: can I control device from LUA?

Post 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?
Hans
User avatar
waltervl
Posts: 5904
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: can I control device from LUA?

Post by waltervl »

I think the method with Lua would be to use a domoticz api JSON with Lua OpenUrl command array.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
jannl
Posts: 673
Joined: Thursday 02 October 2014 6:36
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.2
Location: Geleen
Contact:

Re: can I control device from LUA?

Post 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.
HvdW
Posts: 617
Joined: Sunday 01 November 2015 22:45
Target OS: Raspberry Pi / ODroid
Domoticz version: 2023.2
Location: Twente
Contact:

Re: can I control device from LUA?

Post 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-) !!
Bugs bug me.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest