LUA and dummy contact switch

Moderator: leecollings

Post Reply
fergalom
Posts: 74
Joined: Thursday 24 September 2015 11:44
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

LUA and dummy contact switch

Post 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?
fergalom
Posts: 74
Joined: Thursday 24 September 2015 11:44
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: LUA and dummy contact switch

Post by fergalom »

answer my own query.

use commandArray['UpdateDevice']='idx|nValue|sValue' instead of commandArray['Back Door']='Open'
User avatar
jvdz
Posts: 2334
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: LUA and dummy contact switch

Post by jvdz »

Just use "On" or "Off" to set the status of a switch, not "Open".

Jos
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
tigo72
Posts: 22
Joined: Friday 13 March 2015 9:19
Target OS: Linux
Domoticz version: Beta
Contact:

Re: LUA and dummy contact switch

Post 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:
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest