Autor Thema: [solved] How to perform a command after 30 seconds  (Gelesen 224 mal)

Offline alex

  • New Member
  • *
  • Beiträge: 32
[solved] How to perform a command after 30 seconds
« am: 13 September 2017, 19:35:36 »
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
« Letzte Änderung: 14 September 2017, 21:33:23 von alex »

Offline Otto123

  • Hero Member
  • *****
  • Beiträge: 6600
    • Otto's Technik Blog
Antw:How to perform a command after 30 seconds
« Antwort #1 am: 13 September 2017, 19:46:56 »
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
« Letzte Änderung: 13 September 2017, 19:49:14 von Otto123 »
Viele Grüße aus Leipzig
RaspberryPi,HMLAN,HMUART,Homematic,Fritz!Box 7490,Sonos,ET9200,Arduino nano,ESP8266

Offline alex

  • New Member
  • *
  • Beiträge: 32
Antw:How to perform a command after 30 seconds
« Antwort #2 am: 13 September 2017, 22:27:04 »
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

Offline Otto123

  • Hero Member
  • *****
  • Beiträge: 6600
    • Otto's Technik Blog
Antw:How to perform a command after 30 seconds
« Antwort #3 am: 13 September 2017, 22:42:05 »
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
« Letzte Änderung: 14 September 2017, 00:02:30 von Otto123 »
Viele Grüße aus Leipzig
RaspberryPi,HMLAN,HMUART,Homematic,Fritz!Box 7490,Sonos,ET9200,Arduino nano,ESP8266

Offline MadMax-FHEM

  • Hero Member
  • *****
  • Beiträge: 2205
  • Niveau ist keine Creme...
Antw:How to perform a command after 30 seconds
« Antwort #4 am: 13 September 2017, 22:56:37 »
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 5.8 Pi 2, HM-CFG-USB2, 8x HM-TC-IT-WM-W-EU, 5x HM-CC-RT-DN, 5x HM-SEC-SC-2, 1x HM-WDS10-TH-O, 1x HM-DIS-WM55
FHEM 5.8 PI B+, HM-CFG-USB2, 7x HM-CC-RT-DN, 3x HM-TC-IT-WM-W-EU, 4x HM-Sec-SCo
FHEM 5.8 PI 2 (Testsystem), CUL868, 1x HM-TC-IT-WM-W-EU, 1x HumTempESP8266, 1x mySensorsFillingLevel

Offline Otto123

  • Hero Member
  • *****
  • Beiträge: 6600
    • Otto's Technik Blog
Antw:How to perform a command after 30 seconds
« Antwort #5 am: 13 September 2017, 23:57:40 »
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.
« Letzte Änderung: 14 September 2017, 00:07:25 von Otto123 »
Viele Grüße aus Leipzig
RaspberryPi,HMLAN,HMUART,Homematic,Fritz!Box 7490,Sonos,ET9200,Arduino nano,ESP8266

Offline alex

  • New Member
  • *
  • Beiträge: 32
Antw:How to perform a command after 30 seconds
« Antwort #6 am: 14 September 2017, 15:14:13 »
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

Offline alex

  • New Member
  • *
  • Beiträge: 32
Antw:How to perform a command after 30 seconds
« Antwort #7 am: 14 September 2017, 17:14:30 »
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
Gefällt mir Gefällt mir x 1 Liste anzeigen

Offline MadMax-FHEM

  • Hero Member
  • *****
  • Beiträge: 2205
  • Niveau ist keine Creme...
Antw:How to perform a command after 30 seconds
« Antwort #8 am: 14 September 2017, 21:25:30 »
HURRAY! ;)

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

[solved] How to perform a command after 30 seconds

Bye, Joachim
FHEM 5.8 Pi 2, HM-CFG-USB2, 8x HM-TC-IT-WM-W-EU, 5x HM-CC-RT-DN, 5x HM-SEC-SC-2, 1x HM-WDS10-TH-O, 1x HM-DIS-WM55
FHEM 5.8 PI B+, HM-CFG-USB2, 7x HM-CC-RT-DN, 3x HM-TC-IT-WM-W-EU, 4x HM-Sec-SCo
FHEM 5.8 PI 2 (Testsystem), CUL868, 1x HM-TC-IT-WM-W-EU, 1x HumTempESP8266, 1x mySensorsFillingLevel