Page 1 of 1

LUA and dummy contact switch

Posted: Wednesday 07 October 2015 13:49
by fergalom
Can you change the status of a contact switch through LUA?

I am trying the code below but it does not function

Code: Select all

commandArray = {}

if (devicechanged['test'] == 'On' and otherdevices['Back Door'] == 'Closed') then
   commandArray['Back Door']='Open'
   print('Back Door Open')
else commandArray['Back Door']='Closed'
end

return commandArray
Test is a dummy on/off
Back Door is a dummy contact and showing closed.

Turn test on should open Back Door contact?

Re: LUA and dummy contact switch

Posted: Wednesday 07 October 2015 16:21
by fergalom
answer my own query.

use commandArray['UpdateDevice']='idx|nValue|sValue' instead of commandArray['Back Door']='Open'

Re: LUA and dummy contact switch

Posted: Wednesday 07 October 2015 16:27
by jvdz
Just use "On" or "Off" to set the status of a switch, not "Open".

Jos

Re: LUA and dummy contact switch

Posted: Friday 27 November 2015 16:24
by tigo72
I was having the same question. I want to change the status of the contact sensor (Fibaro Hardware) since often I get false positives: the door is shut but Domoticz tells me it's open. I would like to have a virtual toggle to solve this.

I tried the script you provide, also with the alternative line, and also using "On" instead of "Open" and the like, but it doesn't work for me.

I am not sure what to enter for the nValue and sValue, perhaps that's the problem?

Any help would be much appreciated.

Thx, Tigo

EDIT: got it: 'idx-number|1|open' and 'idx-number|0|closed' works... Problem solved. :mrgreen: