Get dimmer level with LUA
Moderator: leecollings
- Westcott
- Posts: 423
- Joined: Tuesday 09 December 2014 17:04
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Location: UK - Glos
- Contact:
Get dimmer level with LUA
How do you GET the level of a dimmer with LUA?
Zwave - Sigma Z+ stick, Fibaro, Horstmann, Neo Coolcam, EUROtronic
RFlink - IR detectors and temperatures
Wifi - YeeLights, ESP32s, Anoop sockets
Zigbee - lots with zigbee2mqtt and ZbBridge
RFlink - IR detectors and temperatures
Wifi - YeeLights, ESP32s, Anoop sockets
Zigbee - lots with zigbee2mqtt and ZbBridge
- jvdz
- Posts: 2333
- Joined: Tuesday 30 December 2014 19:25
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.107
- Location: Netherlands
- Contact:
Re: Get dimmer level with LUA
otherdevices_svalues['dimmername'] ?
Jos
Jos
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
- sisaenkov
- Posts: 50
- Joined: Friday 27 May 2016 7:21
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 3.8
- Location: Moscow, Russia
- Contact:
Re: Get dimmer level with LUA
Hello!
I also want to get dimmer level on LUA from JSON parameter "Level" :.
JSON parameter stores dimmer slider position instead of otherdevices_svalues['dimmername'] that is only shows current percentage when it's turned On.
Now I have to use variables as Level storage. But this is not the best solution (also curl with jq).
I also want to get dimmer level on LUA from JSON parameter "Level" :.
JSON parameter stores dimmer slider position instead of otherdevices_svalues['dimmername'] that is only shows current percentage when it's turned On.
Now I have to use variables as Level storage. But this is not the best solution (also curl with jq).
Re: Get dimmer level with LUA
Hi,sisaenkov wrote:Hello!
I also want to get dimmer level on LUA from JSON parameter "Level" :.
JSON parameter stores dimmer slider position instead of otherdevices_svalues['dimmername'] that is only shows current percentage when it's turned On.
Now I have to use variables as Level storage. But this is not the best solution (also curl with jq).
Can you share your solution?
I am trying to do the same, but my LUA script hangs.

viewtopic.php?f=61&t=18375
- sisaenkov
- Posts: 50
- Joined: Friday 27 May 2016 7:21
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 3.8
- Location: Moscow, Russia
- Contact:
Re: Get dimmer level with LUA
Here are necessary code blocks:madrian wrote: Can you share your solution?
(The key strings for you contains "uservariables")
Code: Select all
idx = 383
commandArray = {}
function getname(deviceIDX)
for i, v in pairs(otherdevices_idx) do
if v == deviceIDX then
return i
end
end
return 0
end
DomDevice = getname(idx)
if devicechanged[DomDevice] then
if tonumber(otherdevices_svalues[DomDevice]) ~= tonumber(uservariables['Dimmer_' .. idx]:match("(%d+)")) then
if (devicechanged[DomDevice] == 'Off') then
DomValue = 0
print (DomDevice ..": Turn Off")
datasend()
elseif (devicechanged[DomDevice] == 'On') then
print (DomDevice ..": Turn On without level change")
else
DomValue = (otherdevices_svalues[DomDevice]);
print (DomDevice ..": Dimming to " .. (DomValue) .. "%");
datasend()
end
elseif (tonumber(otherdevices_svalues[DomDevice]) ~= tonumber(uservariables['Dimmer_' .. idx]:match(",(%d+)")) and devicechanged[DomDevice] == 'On') then
DomValue = tonumber(uservariables['Dimmer_' .. idx]:match(",(%d+)"))
print (DomDevice ..": Turn On")
datasend()
end
end
return commandArray
Who is online
Users browsing this forum: No registered users and 1 guest