[solved] How to perform a command after 30 seconds

Begonnen von alex, 13 September 2017, 19:35:36

Vorheriges Thema - Nächstes Thema

alex

I need some help with the following challenge. I want to set an alarm on the refrigirator when the door is opened for longer than 30 seconds (or whatever time).
I've mounted a homematic doorsensor on the frig called door_koelkast and it works off course perfectly when I create a normal notify for this.
But now I only want a message to be sent when the door is open longer than 30 seconds. Probably it can be done with a DOIF statement but I can't figure it out yet.

Currently I have the following defined:
define deur_koelkast CUL_HM 5403C3
attr deur_koelkast IODev HMLAN1
attr deur_koelkast IOgrp vccu:HMLAN1
define di_koelkast DOIF ([deur_koelkast:open]) (set pushover msg "koelkast staat nog open")

Any suggestions to get the 30 seconds in here?

Thanks,
Alex

Otto123

#1
Hi Alex,

with DOIF like thisdefine di_koelkast DOIF ([deur_koelkast:"open"]) (set pushover msg "koelkast staat nog open")
attr di_koelkast do resetwait
attr di_koelkast wait 0,30

The DOIF will be triggered with the Event open from the device deur_koelkast - may be, you have to check this on behalf of the Event Monitor.
The Timer will be reset, if the door is closed in a time lower than 30 sec.

Enjoy
Otto
Viele Grüße aus Leipzig  ⇉  nächster Stammtisch an der Lindennaundorfer Mühle
RaspberryPi B B+ B2 B3 B3+ ZeroW,HMLAN,HMUART,Homematic,Fritz!Box 7590,WRT3200ACS-OpenWrt,Sonos,VU+,Arduino nano,ESP8266,MQTT,Zigbee,deconz

alex

Hello Otto,

Thanks for the help. I assume it had to be (30,0 instead of 0,30):

attr di_koelkast do resetwait
attr di_koelkast wait 30,0


This causes the command to be executed 30 seconds after the door has been opened, but it doesn't reset. So even if I close the door within the 30 seconds, it still sends the command.

any thoughts?

Thanks,
Alex

Otto123

#3
Sorry, of course you have to use only attr di_koelkast wait 30 you have only one command. I copied this and I have two  ;)
To reset the wait Timer, the state of the DOIF must changed, the condition must be false. Sometimes I don't understand the DOIFs behavior  ;D

We could change the trigger from event only to check the statedefmod di_koelkast DOIF ([deur_koelkast] eq "open") (set pushover msg "koelkast staat nog open")

crossing the fingers
Otto
Viele Grüße aus Leipzig  ⇉  nächster Stammtisch an der Lindennaundorfer Mühle
RaspberryPi B B+ B2 B3 B3+ ZeroW,HMLAN,HMUART,Homematic,Fritz!Box 7590,WRT3200ACS-OpenWrt,Sonos,VU+,Arduino nano,ESP8266,MQTT,Zigbee,deconz

MadMax-FHEM

What about watchdog?

As I understand watchdog that's exactly what it should do?

But just as idea, I never used watchdog...

When I do things like that I "defmod" an "at" for the timeout and call a function in myUtils that checks again...

If still the case I do what has to be done...
...otherwise I (the function) does just nothing (maybe an entry in the log)...

I know my (actual) "solution" is crap but it works and is (actually) the least thing to be changed...
...other nicer things to do... ;)

Regards, Joachim
FHEM PI3B+ Bullseye: HM-CFG-USB, 40x HM, ZWave-USB, 13x ZWave, EnOcean-PI, 15x EnOcean, HUE/deCONZ, CO2, ESP-Multisensor, Shelly, alexa-fhem, ...
FHEM PI2 Buster: HM-CFG-USB, 25x HM, ZWave-USB, 4x ZWave, EnOcean-PI, 3x EnOcean, Shelly, ha-bridge, ...
FHEM PI3 Buster (Test)

Otto123

#5
Sorry, my proposal is going the wrong direction, it's only extending the waiting time for cmd_1
I have tested this:
defmod di_koelkast DOIF ([deur_koelkast] eq "open") (set pushover msg "koelkast staat nog open") DOELSEIF ([deur_koelkast] eq "closed")()
If the door is closed, the DOIF is going to cmd_2 and no Message is send.
Viele Grüße aus Leipzig  ⇉  nächster Stammtisch an der Lindennaundorfer Mühle
RaspberryPi B B+ B2 B3 B3+ ZeroW,HMLAN,HMUART,Homematic,Fritz!Box 7590,WRT3200ACS-OpenWrt,Sonos,VU+,Arduino nano,ESP8266,MQTT,Zigbee,deconz

alex

No problem Otto, already learned a lot playing around with the DOIF function.
But looking at the Watchdog function as Joachim (Thanks for mentioning!) mentions than I think that is a better function to use in this case. Didn't had time to try it yet but will let you know what comes out of it.

Thanks,
Alex

alex

Yes, the watchdog function definitely solves my question. I have now the following:

define wd_koelkast watchdog deur_koelkast:open 00:00:30 deur_koelkast:closed set pushover msg "koelkast staat nog open"
attr wd_koelkast autoRestart 1

MadMax-FHEM

HURRAY! ;)

So then mark the thread as solved rename e.g.:

[solved] How to perform a command after 30 seconds

Bye, Joachim
FHEM PI3B+ Bullseye: HM-CFG-USB, 40x HM, ZWave-USB, 13x ZWave, EnOcean-PI, 15x EnOcean, HUE/deCONZ, CO2, ESP-Multisensor, Shelly, alexa-fhem, ...
FHEM PI2 Buster: HM-CFG-USB, 25x HM, ZWave-USB, 4x ZWave, EnOcean-PI, 3x EnOcean, Shelly, ha-bridge, ...
FHEM PI3 Buster (Test)