Page 1 of 1

Simple Script does not function: Am I too stupid?

Posted: Saturday 07 September 2019 22:43
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
}

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

Posted: Saturday 07 September 2019 23:10
by boum
The string equality test is case sensitive. You should probably check the variable against "Off"

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

Posted: Sunday 08 September 2019 12:33
by fotomann100
Thats it - Thank you!