Page 1 of 1

How to detect if shutter is opened or closed

Posted: Thursday 24 February 2022 14:32
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
}

Re: How to detect if shutter is opened or closed

Posted: Thursday 24 February 2022 14:51
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 )

Re: How to detect if shutter is opened or closed

Posted: Thursday 24 February 2022 17:41
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?

Re: How to detect if shutter is opened or closed

Posted: Thursday 24 February 2022 21:34
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.