Blinder script  [Solved]

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

Moderator: leecollings

Post Reply
User avatar
Varazir
Posts: 429
Joined: Friday 20 February 2015 22:23
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:

Blinder script

Post 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
}
Raspberry PI 2 with RaZberry Controller 2016 ZWave+ and CC2531(zigbee)
Several IKEA devices/z-wave devices
User avatar
waltervl
Posts: 5853
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Blinder script

Post 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?
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
User avatar
Varazir
Posts: 429
Joined: Friday 20 February 2015 22:23
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:

Re: Blinder script

Post 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
Raspberry PI 2 with RaZberry Controller 2016 ZWave+ and CC2531(zigbee)
Several IKEA devices/z-wave devices
User avatar
Varazir
Posts: 429
Joined: Friday 20 February 2015 22:23
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:

Re: Blinder script

Post 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
Raspberry PI 2 with RaZberry Controller 2016 ZWave+ and CC2531(zigbee)
Several IKEA devices/z-wave devices
User avatar
waltervl
Posts: 5853
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Blinder script

Post 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
}
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
User avatar
Varazir
Posts: 429
Joined: Friday 20 February 2015 22:23
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:

Re: Blinder script

Post 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.
Raspberry PI 2 with RaZberry Controller 2016 ZWave+ and CC2531(zigbee)
Several IKEA devices/z-wave devices
User avatar
waltervl
Posts: 5853
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Blinder script  [Solved]

Post 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
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
User avatar
Varazir
Posts: 429
Joined: Friday 20 February 2015 22:23
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:

Re: Blinder script

Post 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
}
Raspberry PI 2 with RaZberry Controller 2016 ZWave+ and CC2531(zigbee)
Several IKEA devices/z-wave devices
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest