What is wrong with my parantheses?

Moderator: leecollings

Post Reply
User avatar
havnegata
Posts: 114
Joined: Wednesday 10 September 2014 11:05
Target OS: Raspberry Pi / ODroid
Domoticz version: V4.10162
Location: Norway
Contact:

What is wrong with my parantheses?

Post by havnegata »

Raspberry Pi
V3.8035

There are two motion sensors, one virtual switch and a group of lights, and this script gives me the error:
scripts/lua/script_device_lysPåNatt.lua:3: 'then' expected near ')'

What's wrong with the parantheses?

Code: Select all

commandArray = {}

if ((devicechanged['Bevegelse Neo'] == 'On') or (devicechanged['Bevegelse'] == 'Motion')) and ((otherdevices['Natta']) == 'On') and (otherdevices['Group:Lys stue']) == 'On')) then
		commandArray['TomStue']='Off'
		print ("Noen har våknet og lyset er på igjen")	
if (uservariables['Natta'] == 0) then
		commandArray['SendNotification']='Noen har våknet og lyset er på igjen'
		commandArray['Variable:Natta']=tostring (1)
end
end
return commandArray
Doler
Posts: 147
Joined: Friday 31 July 2015 21:02
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Sint-Oedenrode, Netherlands
Contact:

Re: What is wrong with my parantheses?

Post by Doler »

Code: Select all

...((otherdevices['Natta']) == 'On')...
There is a closing parenthesis too much just after ['Natta'].
Mark: Domoticz Beta on Raspberry Pi 4 running Debian Bookworm - Z-Stick 7 - RFXCom - P1 - MySensors - SolarEdge - Dahua - Philips Hue - Docker - Zigbee2mqtt (plugin) - Zwave-js-ui - dzVents - Nodered
User avatar
K3rryBlue
Posts: 77
Joined: Tuesday 07 February 2017 22:13
Target OS: Raspberry Pi / ODroid
Domoticz version: V4.10xx
Location: Netherlands
Contact:

Re: What is wrong with my parantheses?

Post by K3rryBlue »

Please use corrected code below.
There are 2 errors with parantheses. Use notepad++, it will help you detecting the error.

Code: Select all

commandArray = {}

if ((devicechanged['Bevegelse Neo'] == 'On') or (devicechanged['Bevegelse'] == 'Motion')) and ( (otherdevices['Natta'] == 'On') and (otherdevices['Group:Lys stue'] == 'On')) then
      commandArray['TomStue']='Off'
      print ("Noen har våknet og lyset er på igjen")   
if (uservariables['Natta'] == 0) then
      commandArray['SendNotification']='Noen har våknet og lyset er på igjen'
      commandArray['Variable:Natta']=tostring (1)
end
end
return commandArray
Image
Domoticz V4.10717, RPi2 -> Linux raspberrypi 4.4.47-v7+ , RFXCOM - RFXtrx433 USB 433.92MHz ,RAZBERRY2 and OpenZWave USB Version: 1.4-2363-g1f10253-dirty
User avatar
havnegata
Posts: 114
Joined: Wednesday 10 September 2014 11:05
Target OS: Raspberry Pi / ODroid
Domoticz version: V4.10162
Location: Norway
Contact:

Re: What is wrong with my parantheses?

Post by havnegata »

Thanks both of you! Works perfectly now

Sent from my Nexus 6P using Tapatalk
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest