Page 1 of 1

Action On parameter dimmer level

Posted: Tuesday 26 January 2016 22:30
by jautem
Hye,
Does somebody knows if i can retrieve the level of a dummy dimmable switch to inject into ACTION ON URL , when i move the slider of the switch, this command is executed :
/cuisine.php?code=On , and i want to add the percent level to my URL , something like that : &level=[level] ?!

Is there some existing variable at the execution time that can be used ?? thanks for advice

Just for context : a moteino is connected to raspberry serial line , and IR LED send NEC code to a led stripe

Re: Action On parameter dimmer level

Posted: Wednesday 27 January 2016 4:25
by nayr
try a script_device_*.lua script like this:

Code: Select all

commandArray = {}
if (otherdevices['My Device'] == 'On') then
        commandArray['OpenURL']="127.0.0.1/cuisine.php?code=On&level=" .. otherdevices_svalues["My Device"]
end
return commandArray

Re: Action On parameter dimmer level

Posted: Wednesday 27 January 2016 12:20
by jautem
thanks to you for answer , it's a good alternative if gui don't permit de retrieve level value.

But the property level is empty , in gui i got " Set Level: 53 %, Level: 53 %" , but in otherdevices_svalues['Cuisine_Led'] , printed in debug i got zero ??!!!

Do you have an idea ?

Re: Action On parameter dimmer level

Posted: Wednesday 27 January 2016 14:44
by jautem
This is solved now !! , here the final script working fine :

commandArray = {}
if (devicechanged['Cuisine_Led'] ) then
if (otherdevices['Cuisine_Led'] == 'Set Level') then
commandArray['OpenURL']="127.0.0.1/cuisine.php?code=Dim&level=" .. otherdevices_svalues['Cuisine_Led']
print('Level : '..tonumber(otherdevices_svalues['Cuisine_Led']))
end
return commandArray

The difference is to test equality with "Set Level" string , with this the array other devices_svalues handle the right level

Thanks again . :D

Re: Action On parameter dimmer level

Posted: Sunday 28 February 2016 16:58
by deennoo
Great ! Thanks for this.

Got same needed using Milight.
Level can't be handel on lua.

I plan to use a IR remote to drive the TV corner.
IR gateway is made with a rpi lirc and irexec.
Actually can drive scene, and turn on and off TV corner.

Got 2 buttons who are plan to drive milight dimmer one for up one for down.

Each button hit have to set dimmer +5 or -5% from thé actual level.

Off course, if light is off first press on UP button have to set light on and to 5%.

Will try to use your script.

Re: Action On parameter dimmer level

Posted: Thursday 23 March 2017 22:15
by madrian
Anybody can help me with this (Dummy Dimmer)?

script_device_VU.lua:

Code: Select all

commandArray = {}
if (devicechanged['VU'] ) then
if (otherdevices['VU'] == 'Set Level') then
commandArray['OpenURL']="http://192.168.1.99/web/vol?set=" .. otherdevices_svalues['VU']
print('Level : '..tonumber(otherdevices_svalues['VU']))
end
end
return commandArray
In log:

2017-03-23 22:07:13.005 User: Admin initiated a switch command (37/VU/Set Level)

and no Level:..... what is in the script. So it's not working. Any ideas?

Re: Action On parameter dimmer level

Posted: Sunday 24 February 2019 16:54
by salvacalatayud
I'm testing this script:

Code: Select all

commandArray = {}
if (devicechanged['Persiana_papas'] ) then
if (otherdevices['Persiana_papas'] == 'Set Level') then
commandArray['OpenURL']="http://192.168.0.117/cm?cmnd=shutterposition%20" .. otherdevices_svalues['Persiana_papas']
print('Level : '..tonumber(otherdevices_svalues['Persiana_papas']))
end
return commandArray
And get this error:

2019-02-24 16:53:00.212 Error: EventSystem: in prueba slider persiana: [string "--..."]:32: 'end' expected (to close 'if' at line 26) near <eof>

Line 26 is: if (devicechanged['Persiana_papas'] ) then

Any idea?