Page 1 of 1

Sensor status update

Posted: Wednesday 07 March 2018 17:45
by gbuico
Hi everyone.
I need your help to understand if my understanding on how Domoticz dals with devices is correct.
Background. I have a push button connected into an input of a Piface card directly plugged on my domoticz Raspberry.
Everything works fine, but from time to time (average 10 days) a device is triggered as if somebody pushed the button... but nobody did it.
From the device log I see that the button goes on and off within the same second (no milliseconds available in Domoticz :( )
I think we all agree that this should be something due to an electrical interference (bounce).

In this scenario I'm trying to fix the issue by adding the following logic in the LUA device event:
1) the event is triggered by a device change
2) if the triggered device is the push button (information in DeviceChanged) then I go to read again the status of the push button via using the OtherDevice function assuming that the time between the triggering event and the re-read is longer than the "bounce"

The question is: am I correct when I assume that the OtherDevice function is re-reading the status of the push button?
If not, do you have an alternative way to deal with this issue withe a "software trick" to avoid adding electronic components?

The current event is here:

Code: Select all

commandArray = {}
    time = os.date("%x %X")
    for name, value in pairs(devicechanged) do 
		    deviceValue = value --Store value of the device changed to deviceValue variable
	    	deviceName = name --Store name of the device changed to deviceName variable
	end
    if deviceName == 'Shutters Up'
        then
        if deviceValue == 'On'    
            then
            print ('DEVICECHANGED '..deviceName..' '..deviceValue)    
            for deviceName,deviceValue in pairs(otherdevices) do
                if (deviceName=='Shutters Up') 
                    then
                    print ('OTHERDEVICES '..deviceName..' '..deviceValue) 
                    commandArray['SendNotification']=(time .. ' OPEN SHUTTER TRIGGERED ' .. deviceValue)
                    if deviceValue == 'On'
                        then
                        print ('OPENING SHUTTERS') 
                        commandArray['All shutters'] = 'On'
                        end
                    end
                end
            end    
        end    
    if deviceName == 'Shutters Down'
        then
        if deviceValue == 'On'    
            then
            commandArray['All shutters'] = 'Off'
            end
        end    
return commandArray
Thanks for reading till here ;)

Giacomo