Dimming, how to go back to former state

Must be cleaned all topics go to the right subforum
Post Reply
Melissen
Posts: 41
Joined: Wednesday 16 November 2016 10:39
Target OS: -
Domoticz version:
Contact:

Dimming, how to go back to former state

Post by Melissen » Wednesday 23 November 2016 19:31

Hi,

I'm very new to Domoticz and LUA. Although I had an education in programming (1985-1993) in Basic and GWBasic, this is a little bit different.
I want to make a script that turns a dimmer back to it's former state.

I want to dim the spots in my kitchen to 5% when I activate all other lamps in my livingroom. (this is easy with a standard Scene or Group).
So this is not the problem.

Now when I'm in the kitchen I activate a swith to turn the spots to 100%. When I leave the kitchen and press the 'off-switch' the spots goes out. But I want them to turn back to 5%.
When the lamps in the room aren't ON (group is off by switch). And I enter the kitchen and push the switch the spots must go to 100%, and when I put the switch off, the spots have to go OUT (because the roomlamps are OUT also)

How should I make this script? When I see a working script, I'll understand LUA much better and will be able to solve this kind of problems much more easier...

Thanks in advantage,

Hein Melissen (the Netherlands)
RFXcom433e ver1009,Raspberry Pi,Domoticz v3.5877

KaKu:16c remote,dimmer,wall-sockets,sunscreenswitch
Promax:wall sockets Elro:wall sockets Somfy:RFY screens
TFA:weather station Chinese temperature sensors, smoke detectors, power switches

User avatar
jvdz
Posts: 1191
Joined: Tuesday 30 December 2014 20:25
Target OS: Raspberry Pi
Domoticz version: Stable
Location: Westland/Netherlands
Contact:

Re: Dimming, how to go back to former state

Post by jvdz » Wednesday 23 November 2016 20:00

Not sure if this is something that would work for you but might get you going. Save this code a device script:

Code: Select all

commandArray = {}

-- Switch Keuken on / Off when Tafel lamp is switched
if devicechanged("Tafel") ~= "Off" then
	commandArray['Keuken'] = 'Set Level 5'
elsif devicechanged("Tafel") == "Off" then
	commandArray['Keuken'] = 'Off'
end
-- Switch Keuken to 5% when tafel is On
if devicechanged("Keuken") == "Off" and otherdevices['Tafel'] ~= "Off" then
	commandArray['Keuken'] = 'Set Level 5'
end

return commandArray
This code uses one other Lamp as trigger and control .

Hope this helps,
Jos

Melissen
Posts: 41
Joined: Wednesday 16 November 2016 10:39
Target OS: -
Domoticz version:
Contact:

Re: Dimming, how to go back to former state

Post by Melissen » Wednesday 23 November 2016 22:08

Hi Jos,

I use 5 ProMax switches from Action to turn on my livingroom lamps. I programmed them with one unique code to switch them on/off separatly. number 1 to 5. I also programmed them with one 'same' code 16.
On my switches-screen I can turn every lamp on or off by selecting that lamp. (RFXcom send signal 1, 2, 3, 4 or 5)
On my swiches-screen I also got 'ALL Lamps', So I can put them on or off by one-click (RFXcom sends signal 16)

In my groups-screen I made a group 'All Lamps' and added the switch 'ALL Lamps' and is triggered by a remote (KIKA 16channel) on selector1,button1.
So I can use a remote to switch the ProMax-swtiches.
They are only 'software'connected not 'hardware"connected

The dimmer is activated by RFXcom with a self made code (switch) which is stored in the dimmer. percentage 5% (called dimmer low)
The dimmer also gets it's own remote on the wall (AWST-8800)

Now I added the dimmer in the group 'ALL Lamps' . So by pressing selector1,button1. The switches 'all lamps' and 'dimmer low' are activated.

I also made a switch 'dimmer high'. percentage 100%... when I push the AWST-8800 the spots will burn at maximum. But when I turned switch 'dimmer high off, the spots will go off, instead back to 5%

Hope this will help you...

selector1,button1 is called '16k 1 1'
Image

So how can I see if a remote is pressed in LUA? Instead of a switch is goen from On to OFF?

I think I will leave the DIMMER on and only use the percentages 0% 5% and 100%. Because when switching from switch LOW and HIGH the dimmer goes first off, then back to maximum and then dims to 5%...
So I have to read out the percentage of the dimmer in LUA.

So a example off the script (not in LUA)
If 16k 1 1 is ON AND DIMMER=0%, turn on ALL LAMPS and DIMMER=5%
if 16k 1 1 is ON AND DIMMER=100%, turn on ALL LAMPS
if 16k 1 1 is OFF AND DIMMER=5%, turn off ALL lAMPS and DIMMER=0%
if 16k 1 1 is OFF AND DIMMER=100%, turn off ALL LAMPS

if ALL LAMPS = ON and AMST8800 is ON, DIMMER=100%
if ALL lAMPS = ON and AMST8800 switches to OFF, DIMMER=5%
If ALL lamps = OFF and AMST8800 is switched to OFF, DIMMER=0%
If ALL Lamps = OFF and AMST8800 is switched to ON, DIMMER= 100%
RFXcom433e ver1009,Raspberry Pi,Domoticz v3.5877

KaKu:16c remote,dimmer,wall-sockets,sunscreenswitch
Promax:wall sockets Elro:wall sockets Somfy:RFY screens
TFA:weather station Chinese temperature sensors, smoke detectors, power switches

Melissen
Posts: 41
Joined: Wednesday 16 November 2016 10:39
Target OS: -
Domoticz version:
Contact:

Re: Dimming, how to go back to former state

Post by Melissen » Thursday 24 November 2016 0:24

Hohoho, Just made it... Now I can use a script for using a remotebutton to activate a switch...
Now this is the first step in my final script... but I'm understanding a little bit of LUA right now.
Forgot to put a V at 'Event Active' when I made a script for letting it work....

commandArray = {}

if (devicechanged['16k 4 1']=='On' and otherdevices['action 2B']=='Off') then
commandArray['action 2B']='On'
end

if (devicechanged['16k 4 1']=='Off' and otherdevices['action 2B']=='On') then
commandArray['action 2B']='Off'
end

return commandArray




Now I need to find out how I get the data for the dimmer....
RFXcom433e ver1009,Raspberry Pi,Domoticz v3.5877

KaKu:16c remote,dimmer,wall-sockets,sunscreenswitch
Promax:wall sockets Elro:wall sockets Somfy:RFY screens
TFA:weather station Chinese temperature sensors, smoke detectors, power switches

pvm
Posts: 926
Joined: Tuesday 17 June 2014 22:14
Target OS: NAS (Synology & others)
Domoticz version: Stable
Location: NL
Contact:

Re: Dimming, how to go back to former state

Post by pvm » Thursday 24 November 2016 21:56

A lot of examples at : http://www.domoticz.com/wiki/Category:Lua they might be of help to you
Synology NAS, PI3, ZWave, Xiamo zigbee devices, BTLE plant sensor

Melissen
Posts: 41
Joined: Wednesday 16 November 2016 10:39
Target OS: -
Domoticz version:
Contact:

Re: Dimming, how to go back to former state

Post by Melissen » Friday 25 November 2016 1:37

Problem solved.... typed everything again, and it works.... Also LUA is more understandable now...

Image
RFXcom433e ver1009,Raspberry Pi,Domoticz v3.5877

KaKu:16c remote,dimmer,wall-sockets,sunscreenswitch
Promax:wall sockets Elro:wall sockets Somfy:RFY screens
TFA:weather station Chinese temperature sensors, smoke detectors, power switches

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests