Solved: Need help with LUA script for Fibaro Dimmer

Moderator: leecollings

Post Reply
RobertH
Posts: 12
Joined: Sunday 15 November 2015 19:10
Target OS: Windows
Domoticz version:
Location: Norway, Kongsberg
Contact:

Solved: Need help with LUA script for Fibaro Dimmer

Post by RobertH »

Hi,

I already have a LUA device script that I am using but I would like to add some additional functionality to it.
This is what I am using now:

Code: Select all

commandArray = {}
if (devicechanged['Stue dimmer S2 1 click'] == 'On') then
   commandArray['Group:LivingRoom']='On'
   elseif 
   (devicechanged['Stue dimmer S2 2 click'] == 'On') then
   commandArray['Group:LivingRoom']='Off'
   elseif
   (devicechanged['Stue dimmer S2 3 click'] == 'On') then
   commandArray['Group:Alt lys']='Off'
end
return commandArray
What I would like to achive is that when "Stue dimmer S2 1 click" is triggered I would like one of three things to happen:
If Group is Off --> Turn On
If Group is Mixed --> Turn On
If Group is On --> Turn Off

And I would also like the 3 click to additionaly turn off the Power device of my harmony hub, its just like a light switch so I just need to know where to put in the device reference. ;)

Hoping someone can help! :)

Merry Christmas!
Last edited by RobertH on Tuesday 05 January 2016 19:14, edited 1 time in total.
Domoticz running on Windows Server 2008 in VMware (ESXi), UZB1 stick, 3x FIBARO FGD212 Dimmer, 1x FIBARO RGBW Controller FGRGBWM-441, 2x FIBARO FGMS001 Motion Sensor and 2x Popp 009006 Plug-in Switch
RobertH
Posts: 12
Joined: Sunday 15 November 2015 19:10
Target OS: Windows
Domoticz version:
Location: Norway, Kongsberg
Contact:

Re: Need help with LUA script for Fibaro Dimmer

Post by RobertH »

After much fiddeling I finally managed to solve it on my own. Here is the solution in case it helps somebody else:

Code: Select all

commandArray = {}
if (devicechanged['Stue dimmer S2 1 click'] == 'On') then
	if (otherdevices['Dimmer Stue'] == 'Off' or otherdevices['Stue lamp 1'] == 'Off' or otherdevices['Stue lamp 2'] == 'Off') then
	commandArray['Group:LivingRoom']='On'
	else
	commandArray['Group:LivingRoom']='Off'
	end
  elseif 
  (devicechanged['Stue dimmer S2 2 click'] == 'On') then
  commandArray['Group:LightAndTV']='On'
  elseif
  (devicechanged['Stue dimmer S2 3 click'] == 'On') then
  commandArray['Group:LightAndTV']='Off'
end
return commandArray
For the Group LightAndTV I included the switch for my Harmony TV activity and for the off action i put in "http://192.168.1.111:8080/json.htm?type ... itchcmd=On" which is the PowerOff Harmony action. :D

Robert
Domoticz running on Windows Server 2008 in VMware (ESXi), UZB1 stick, 3x FIBARO FGD212 Dimmer, 1x FIBARO RGBW Controller FGRGBWM-441, 2x FIBARO FGMS001 Motion Sensor and 2x Popp 009006 Plug-in Switch
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest