Page 1 of 1

Unable to change a device status with LUA

Posted: 28 Dec 2017, 17:17
by gbuico
I'm currently testing how to change the status of an RFLink connected device to Open/Close using a Domoticz event
For this purpose I wrote a very simple LUA security event which is supposed to do the following:
1) When I go on the security panel and press Disarm, I want "Relay 0" to go Off
2) When I go on the security panel and press Arm Away, I want the shutter "Kitchen shutter" to become "Closed"

Function 1 works perfectly, function 2 doesn't work at all.
"Relay 0" is a relay on a Piface Digital 2 directly connected to Raspberry and is defined as Lighting, Impuls, On/Off
"Kitchen shutter" is a Blyss blind controller, interfaced via RFLink and defined as Light/Switch, Blyss, Blinds inverted

An important information is that "Kitchen shutter" is perfectly opening, closing and stopping the movement of the shutters if I change its status from the Device or Dashboard panels of Domoticz.

Here is the LUA code I'm using for test:

Code: Select all

commandArray = {}
        if globalvariables['Security'] == 'Disarmed' 
        then
            commandArray['Relay 0'] = 'Off'
        end
        if globalvariables['Security'] == 'Armed Away' 
        then
            print (otherdevices['Kitchen shutter']) 
            commandArray['Kitchen shutter'] = 'Close'
            print ('here')
            print (otherdevices['Kitchen shutter']) 
        end 
return commandArray
I'm surely doing something wrong.... :(
Any help or suggestion?
Giacomo

Re: Unable to change a device status with LUA

Posted: 28 Dec 2017, 23:29
by gbuico
A quick reply to myself to leave trace of the solution just in case someone else will face the same issue.
The problem is that, even if this device is a Blind and its status is either "Open" or "Closed" the right command to be sent is not "Open" or "Close" but "On" or "Off"
I'm not sure if this is a bug in Domoticz, but changing line 9 of the original LUA event like this:
commandArray['Kitchen shutter'] = 'Off'
fixed my issue.

Hope this will help someone

Giacomo

Re: Unable to change a device status with LUA

Posted: 29 Jan 2018, 18:56
by billyjackson
Thanks! I have changed this line in my code and it fixed my problem too