Page 1 of 1

Switch in combination with Selector

Posted: Tuesday 08 March 2016 6:11
by HansieNL
Naamloos 2.jpg
Naamloos 2.jpg (111.91 KiB) Viewed 6264 times
Naamloos 4.jpg
Naamloos 4.jpg (112.49 KiB) Viewed 6264 times
I got a dimmer switch and a selector switch for my Hue lamp.
If I select Off on the selector switch, the dimmer switch changes also to off status.
If I select Off on dimmer switch, the selector switch stays on last chosen and doesn't change to switched off.
I'm using a hardware dimmer switch and if switched to off it set dimmer switch to off. I want auto switch the selector to off too? Than I can hide dimmer switch and only use selector switch.

Re: Switch in combination with Selector

Posted: Friday 11 March 2016 17:52
by wmn79
I think this can be easily fulfilled with a lua device script. Basically I think it should be something like this:

Code: Select all


commandArray = {}

if devicechanged['Lamp Salontafel 02'] == 'Off' then
   commandArray['Lamp Salontafel']='Set Level 0'
end     

return commandArray

Put above code in a script_device_YourScriptName.lua file and put it in the scripts/lua folder and it should work. Good luck!

Re: Switch in combination with Selector

Posted: Friday 11 March 2016 23:23
by arjanw
Probably set the selector switch as sub device of the dimmer switch ?

Re: Switch in combination with Selector

Posted: Saturday 12 March 2016 9:17
by HansieNL
@arjanw: If I set selector switch as sub device of dimmer switch off button works ok, but when I select one of the other selections after a few seconds off buttons lightens up and selected button isn't lightened up anymore. I tried dimmer switch as sub device of selector switch, but same effect? Looks like there's somewhere a loop?
@wmn79: I tried the script, but same strange behaviour as with sub setting. I can push button from selector switch, but jumps to off button, but off switch is not triggered.
These are the actions for the selector switch...
Naamloos 2.jpg
Naamloos 2.jpg (260.21 KiB) Viewed 6209 times

Re: Switch in combination with Selector

Posted: Sunday 13 March 2016 21:26
by wmn79
Do you get an error in the log? If so what is the error? Did I get the name of the first switch correct? Not sure if it is the letter O or a zero. I think I used a zero in the name. If that is incorrect you need to change it.

Re: Switch in combination with Selector

Posted: Monday 14 March 2016 1:10
by HansieNL
@wmn79: script works fine. If I push for example Halvol the right command is sent to bulb and executed. Lamp Salontafel O2 is on then. Lamp Salontafel (selector switch) button Halfvol lights up for just a second and then Off button lights up. I expect that the selction I made stays light on, or am I missing something.

Re: Switch in combination with Selector

Posted: Monday 14 March 2016 14:04
by wmn79
I don't mean the commands you use in your set levels I mean the LUA script I posted. That script should only be executed if the Lamp Salon tafel 02 (or O2) is changed to off. If you use both the lua script and the command you have with set level 0 you will get in a loop. You better put a check in the LUA if it is off or not. Should be something like this:

Code: Select all

commandArray = {}

if devicechanged['Lamp Salontafel 02'] == 'Off' then
   if otherdevices['Lamp Salontafel']~='Off'
   commandArray['Lamp Salontafel']='Set Level 0'
   end
end     

return commandArray
With the selector switches I have, the last given command keeps being selected. So if I select volume down for my Sonos, it will stay on volume down. Therefore I update the selector switch with the current state (playing, paused or stopped) I don't know why this is different with your selector switch.

Re: Switch in combination with Selector

Posted: Monday 14 March 2016 21:57
by HansieNL
@wmn79: Thx for the tip. I deleted the level 0 command and changed your script to:

commandArray = {}

if devicechanged['Lamp Salontafel O2'] == 'Off' and otherdevices['Lamp Salontafel'] ~='Off' then
commandArray['Lamp Salontafel']='Set Level: 0'
elseif devicechanged['Lamp Salontafel'] == 'Off' and otherdevices['Lamp Salontafel 02'] ~='Off' then
commandArray['Lamp Salontafel O2']='Off'
end

return commandArray

I don't get a sValue ? for the Lamp Salontafel O2 (dimmer switch) and this way I get the best result.

Re: Switch in combination with Selector

Posted: Monday 14 March 2016 23:26
by wmn79
Yes that is right, I don't get sValues with my Hue bulbs as well. Maybe that is something which can be improved by arjanwaard who has really improved the implementation of Hue in Domoticz lately.

Do the switches now work how you want them to work?

Re: Switch in combination with Selector

Posted: Monday 14 March 2016 23:31
by HansieNL
Yep, many thanks for the help.