Page 1 of 1

Blinder script

Posted: Wednesday 16 April 2025 16:48
by Varazir
I can't get this to work.
I have set logging to debug and I can't find any tagged Blinder

Code: Select all

return {
	on = {
		timer = {
			'between 13:00 and 60 minutes before sunset every 05 minutes',
		},
	},
	logging = {
		level = domoticz.LOG_FORCE, -- Select one of LOG_DEBUG, LOG_INFO, LOG_ERROR, LOG_FORCE to override system log level
		marker = "Blinder"
    },
    
	execute = function(dz, device)
	    local function logWrite(str,level)
            dz.log(tostring(str),level or dz.LOG_MODULE_EXEC_INFO)
        end
	    local lux = dz.devices(249)
	    local blinder = dz.devices(83)
	    
            logWrite('10............... LUX ' .. lux )
		
	        if lux <= "1600" then
    		    logWrite('20................It is cloudy outside')
	    	    blinder.open()
    	    else 
    	        logWrite('30................It is sunny outside')
    	        blinder.close()
	    	end 
	end
}

Re: Blinder script

Posted: Wednesday 16 April 2025 20:46
by waltervl
Remove the logwrite function. No need for that.
Use the build in domoticz.log() function as everybody else is using.

There is a logging example template (when you create a new dzvents script) to show the way of working.

Did some AI "help" you creating this script?

Re: Blinder script

Posted: Wednesday 16 April 2025 21:50
by Varazir
waltervl wrote: Wednesday 16 April 2025 20:46 Remove the logwrite function. No need for that.
Use the build in domoticz.log() function as everybody else is using.

There is a logging example template (when you create a new dzvents script) to show the way of working.

Did some AI "help" you creating this script?
This is an old script I found here I think

Re: Blinder script

Posted: Wednesday 16 April 2025 22:13
by Varazir
I don't need to use that script.

I have a blinder in my living room and a Philips light sensor on the balcony attached to the living room.
The room is facing west so I get a lot of sun in the summer.
Have a bloky that works ish, the blinder keeps going up and down when the lux flux close to the trigger value.

I like the script to wait 15 min( x minutes) after it closed the blinder to prevent it go up and down every minute.
It need to be over 20 C as well

Re: Blinder script

Posted: Wednesday 16 April 2025 22:39
by waltervl
This should work as a start

Code: Select all

return {
	on = {
		timer = {
			'every 5 minutes',
		},
	},
	logging = {
		level = domoticz.LOG_INFO, -- Select one of LOG_DEBUG, LOG_INFO, LOG_ERROR, LOG_FORCE to override system log level
		marker = "Blinder"
    },
    
	execute = function(domoticz, device)
	   
	    local lux = domoticz.devices(249)
	    local blinder = domoticz.devices(83)
	    
            domoticz.log('10............... LUX ' .. lux )
		
	        if lux <= "1600" then
    		    domoticz.log('20................It is cloudy outside')
	    	    blinder.open()
    	    else 
    	        domoticz.log('30................It is sunny outside')
    	        blinder.close()
	    end 
	end
}

Re: Blinder script

Posted: Thursday 17 April 2025 10:06
by Varazir
I'm getting this

Code: Select all

2025-04-17 09:45:00.314 Error: dzVents: Blinder: An error occurred when calling event handler dV_SoligtVardagsrum
2025-04-17 09:45:00.314 Error: dzVents: Blinder: ...cripts/dzVents/generated_scripts/dV_SoligtVardagsrum.lua:17: attempt to concatenate a table value (local 'lux')
I guess I need pin point a source on the device.

Re: Blinder script  [Solved]

Posted: Thursday 17 April 2025 17:25
by waltervl
because this

Code: Select all

local lux = domoticz.devices(249)
should be changed into into something like

Code: Select all

local lux = domoticz.devices(249).lux

Re: Blinder script

Posted: Thursday 17 April 2025 18:41
by Varazir
It worked thanks

Code: Select all

return {
	on = {
		timer = {
			'every 5 minutes',
		},
	},
	logging = {
		level = domoticz.LOG_INFO, -- Select one of LOG_DEBUG, LOG_INFO, LOG_ERROR, LOG_FORCE to override system log level
		marker = "Blinder"
    },
    
	execute = function(domoticz, device)
	   
	    local lux = domoticz.devices(368).lux
	    local blinder = domoticz.devices(437)
	    
            domoticz.log('10............... LUX ' .. lux )
		
	        if lux <= 1600 then
    		    domoticz.log('20................It is cloudy outside')
	    	    blinder.open()
    	    else 
    	        domoticz.log('30................It is sunny outside')
    	        blinder.close()
	    end 
	end
}