Simple Script does not function: Am I too stupid?  [Solved]

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
fotomann100
Posts: 16
Joined: Tuesday 27 August 2019 15:18
Target OS: Raspberry Pi / ODroid
Domoticz version: 41017
Contact:

Simple Script does not function: Am I too stupid?

Post by fotomann100 »

I'm a beginner in dzvents, but I try to learn.

I wrote the following very simple script, that does not function. The second "If" will be ignored, but I don't know why. There are no error messages in log. Any advice is wellcome.

Code: Select all

return {
	on = {
		devices = {
			'TestMaster'
		}
	},
	execute = function(domoticz, TestMaster)
	    
	   domoticz.log('Programmablauf gestartet')
	    
	   local TestSlave = domoticz.devices('TestSlave')
	       
	             domoticz.log('Variable gesetzt. TestMaster-Status:')
	             domoticz.log(TestMaster.state)
	    
	   if (TestMaster.state == 'On') then
	       TestSlave.switchOn()
	        domoticz.log('Abfrage erfolgt')
	        
	   else
	        domoticz.log('else gelesen TestMaster Status:')
	        domoticz.log(TestMaster.state)
	       
        
         if (TestMaster.state == 'OFF') then
	         TestSlave.switchOff()
	        domoticz.log(' 2. Abfrage erfolgt')
            
	   end

		   end
		 
    
		        domoticz.log('Durchlauf beendet')
	end
}

Devices in use:
several RFXtrx433XL
Sonoff Basic, Sonoff POW R2 / Tasmota
D1 mini / espeasy
switches and sensors from several china suppliers
Pollin wireless sockets
Renkforce smoke detectors
User avatar
boum
Posts: 135
Joined: Friday 18 January 2019 11:31
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10717
Location: France
Contact:

Re: Simple Script does not function: Am I too stupid?

Post by boum »

The string equality test is case sensitive. You should probably check the variable against "Off"
fotomann100
Posts: 16
Joined: Tuesday 27 August 2019 15:18
Target OS: Raspberry Pi / ODroid
Domoticz version: 41017
Contact:

Re: Simple Script does not function: Am I too stupid? (Solved)  [Solved]

Post by fotomann100 »

Thats it - Thank you!

Devices in use:
several RFXtrx433XL
Sonoff Basic, Sonoff POW R2 / Tasmota
D1 mini / espeasy
switches and sensors from several china suppliers
Pollin wireless sockets
Renkforce smoke detectors
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest