"If the door is open for more than ten minutes --> Send message. Advice needed

Moderator: leecollings

Post Reply
fotomann100
Posts: 16
Joined: Tuesday 27 August 2019 15:18
Target OS: Raspberry Pi / ODroid
Domoticz version: 41017
Contact:

"If the door is open for more than ten minutes --> Send message. Advice needed

Post by fotomann100 »

I'm not able to find a programming solution for the following problem:

I would like to control the status of a garage door. If the door is open for more than ten minutes, Domoticz should send a message via Pushbullet.

I have got a switch, that indicates the door status. Sending a message after ten minutes is also no problem. But the message is sent out also if the door is closed before the ten minutes.

How can I program this right?

Devices in use:
several RFXtrx433XL
Sonoff Basic, Sonoff POW R2 / Tasmota
D1 mini / espeasy
switches and sensors from several china suppliers
Pollin wireless sockets
Renkforce smoke detectors
User avatar
jvdz
Posts: 2334
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: "If the door is open for more than ten minutes --> Send message. Advice needed

Post by jvdz »

Show the script you have to send the message out please so we can see what you are doing, but my guess is your aren't testing the actual switch status.

Jos
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
fotomann100
Posts: 16
Joined: Tuesday 27 August 2019 15:18
Target OS: Raspberry Pi / ODroid
Domoticz version: 41017
Contact:

Re: "If the door is open for more than ten minutes --> Send message. Advice needed

Post by fotomann100 »

I have got several versions of the program with the common ground that they do not work. In the try listed below I'am using a user variable that is set to "1" after 600 seconds.

The notification is sent, when the door status is changing from open to close. There is also a problem with the trigger, the 2. Else-if-part is not executed. In result, the user variable stays in status "1".
Attachments
blockly 02.JPG
blockly 02.JPG (48.55 KiB) Viewed 4542 times

Devices in use:
several RFXtrx433XL
Sonoff Basic, Sonoff POW R2 / Tasmota
D1 mini / espeasy
switches and sensors from several china suppliers
Pollin wireless sockets
Renkforce smoke detectors
User avatar
jvdz
Posts: 2334
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: "If the door is open for more than ten minutes --> Send message. Advice needed

Post by jvdz »

It will never reach the second condition as the first one is valid when the status changes to Open.
I am always using LUA scripts for logic like this, or you could use dzEvent as well as that is also easy to test for the time the switch changed last.

Jos
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
lost
Posts: 662
Joined: Thursday 10 November 2016 9:30
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: "If the door is open for more than ten minutes --> Send message. Advice needed

Post by lost »

fotomann100 wrote: Sunday 01 September 2019 15:40 How can I program this right?
I have done such function, in Lua, a 'bit more complex': Send a mail notification if we are present & auto-close the door if we are not (linked with domoticz security panel status/alarm function) + garage PIR did not trigger since some time (as a security even if door have it's own), in case my children forget to close after leaving with their bicycles...

Code snippet from a lua time script managing several 'simple' functions :

Code: Select all

--
-- Garage door editable settings :
--
devGarageDoorState ='SectGarage'
devGarageDoorCmd   ='CdeSectGge'
devGarageSensMvt   ='MvtGarage'

garageNoMvtSec=30
garageNoMvtAdv=120
garageNoStaSec=180
garageDoorCloseTimeSec=60

-- To be used by checks that do not have to be handled every minute...
CurrentMn = os.date('%M')

--(...)

------------------------
-- GARAGE DOOR CHECKS --
------------------------

-- print('Porte Garage : '..otherdevices[devGarageDoorState])

-- Only check every 5 mn
if ((CurrentMn % 5 == 0) and (otherdevices[devGarageDoorState] == 'Open')) then
    lastMvt=timeLastUpdate(devGarageSensMvt)
    lastCmd=timeLastUpdate(devGarageDoorCmd)
    lastSta=timeLastUpdate(devGarageDoorState)
    
    if ((lastMvt >  garageNoMvtSec) and (lastSta > garageNoStaSec) and (lastCmd >  garageDoorCloseTimeSec)) then
        if (otherdevices[devSecPanel] == 'Arm Away') then
            -- Auto off after 1s set in switch properties
            print('Sending auto-close for '..devGarageDoorCmd..' after no mvt for '..lastMvt..'s & no cmd for '..lastCmd..'s.')
            cmdNb = cmdNb + 1
            commandArray[cmdNb]={[devGarageDoorCmd]='On'}
        else
            if (lastMvt >  garageNoMvtAdv) then
                cmdNb = cmdNb + 1
                commandArray[cmdNb]={['SendEmail'] = 'OUBLI GARAGE ?#'..devGarageDoorState..' : '..otherdevices[devGarageDoorState]..' since '..lastSta..'s ; '..os
.date("%c")..'#'..emailNotifyAlarm}
            end
        end
    end
    
    print('Porte Garage ouverte depuis '..lastSta..'s, dernier mvt/cmd : '..lastMvt..'/'..lastCmd..'s.')
end

--(...)

--------------------------
-- THAT'S ALL FOLKS !!! --
--------------------------

return commandArray

fotomann100
Posts: 16
Joined: Tuesday 27 August 2019 15:18
Target OS: Raspberry Pi / ODroid
Domoticz version: 41017
Contact:

Re: "If the door is open for more than ten minutes --> Send message. Advice needed

Post by fotomann100 »

Hello lost,
thank you for the advice and the code snippet. Tomorrow I will try to understand how it works - sounds interesting.
In the meantime - thank you jvdz - I developed the blockly script and extended it by a dummy switch as a timer: It seems to work, but there is one problem, that I do not understand:

The yellow marked middle part of the script is ignored by domoticz and I don't know why.
Attachments
Unbenannt.JPG
Unbenannt.JPG (56.09 KiB) Viewed 4509 times

Devices in use:
several RFXtrx433XL
Sonoff Basic, Sonoff POW R2 / Tasmota
D1 mini / espeasy
switches and sensors from several china suppliers
Pollin wireless sockets
Renkforce smoke detectors
User avatar
felix63
Posts: 244
Joined: Monday 07 December 2015 9:30
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.1
Location: Gouda
Contact:

Re: "If the door is open for more than ten minutes --> Send message. Advice needed

Post by felix63 »

I use a dzvents script that I adapted from somewhere. See this thread: https://www.domoticz.com/forum/viewtopi ... 72&t=23768
joshua1
Posts: 1
Joined: Wednesday 12 September 2018 15:16
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: Limmen
Contact:

Re: "If the door is open for more than ten minutes --> Send message. Advice needed

Post by joshua1 »

I have done it this way, works o.k.
Attachments
gd2.png
gd2.png (16.16 KiB) Viewed 3299 times
gd1.png
gd1.png (22.85 KiB) Viewed 3299 times
Refhi
Posts: 3
Joined: Monday 24 December 2018 20:15
Target OS: Linux
Domoticz version:
Contact:

Re: "If the door is open for more than ten minutes --> Send message. Advice needed

Post by Refhi »

joshua1 wrote: Sunday 09 May 2021 17:32 I have done it this way, works o.k.
I... I don't understand how that work, but it does !

Well done. And thanks.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest