How to detect if shutter is opened or closed

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

Moderator: leecollings

Post Reply
K0enH
Posts: 32
Joined: Monday 20 March 2017 14:13
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

How to detect if shutter is opened or closed

Post by K0enH »

Hi,

I'm using a dummy shutter device to control my shutter,
based on the dummy an event is triggered.
this was working correctly, however, since last release I need to execute the close and open actions twice to get it working correctly.
from my understanding something changed in detecting if the device was opened or closed, changing the level is still working fine.

any idea on this,
this is the script I'm currently struggling with:

Code: Select all

return {
	on = {
		devices = {
			'Rolluik'
		}
	},
	execute = function(domoticz, device)
    	domoticz.log('Device ' .. device.name .. ' was changed', domoticz.LOG_INFO)
		domoticz.log(device.changed)
		domoticz.log('Selected level' .. device.level)
		domoticz.log(device.status )
		Rolluik = domoticz.devices('Rolluik-Hardware')
		RolluikSwitch = domoticz.devices('Rolluik')
		newpercentage = 100 - device.level
		
		
		
		if(device == 'Closed') then
		Rolluik.switchOff()
		 domoticz.log('sluit rolluik')
        --elseif(device == 'Open' and device.level == 0) then
       	 --domoticz.log('open rolluik')
        --Rolluik.switchOn()
        else
        
        
        domoticz.log(newpercentage)
        	 domoticz.log('zet percentage: '..newpercentage)
        	 Rolluik.dimTo(newpercentage)
        --Rolluik.setLevel(newpercentage)
        
        end
    
	
	end
}
User avatar
waltervl
Posts: 5894
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: How to detect if shutter is opened or closed

Post by waltervl »

It could be that in latest stable the open/close vs On/Off logic for especially Blinds inverted has been changed.
So please check in the Event system user interface (menu Setup - Events) what the Current state values of your blind device is (first script tab, see also https://www.domoticz.com/wiki/Events )
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
K0enH
Posts: 32
Joined: Monday 20 March 2017 14:13
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: How to detect if shutter is opened or closed

Post by K0enH »

thanks for the reply.

I've done a few checks.

-completely closed gives:
Closed with value 1/41

-completely open gives:
Open with value 0/100

-20 percent open gives:
Open with value 2/20

so the value in front of the slash is probably the best indicator.
how can I get this in dzevents?
User avatar
waltervl
Posts: 5894
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: How to detect if shutter is opened or closed

Post by waltervl »

How is that dummy device gets it's data? Because there also seems something wrong. Especially the second value on close.

But to get this values use .nValue for state 0/1/2 and .sValue for 0-100.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest