Unable to change a device status with LUA

Moderators: Voyager, BertB, rtenklooster, Stuntteam

Post Reply
Message
Author
gbuico
Normal user
Posts: 3
Joined: 28 Dec 2017, 16:58

Unable to change a device status with LUA

#1 Post by gbuico » 28 Dec 2017, 17:17

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

gbuico
Normal user
Posts: 3
Joined: 28 Dec 2017, 16:58

Re: Unable to change a device status with LUA

#2 Post by gbuico » 28 Dec 2017, 23:29

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

billyjackson
Normal user
Posts: 2
Joined: 29 Jan 2018, 17:51

Re: Unable to change a device status with LUA

#3 Post by billyjackson » 29 Jan 2018, 18:56

Thanks! I have changed this line in my code and it fixed my problem too
I really like this site

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest