Autor Thema: How to do timeouts in FHEM?  (Gelesen 1565 mal)

Offline jacko

  • New Member
  • *
  • Beiträge: 20
How to do timeouts in FHEM?
« am: 02 Januar 2022, 17:13:36 »
I can't see a way to implement a timeout in fhem. For example, I am controlling a device (in my case a garage door) and I send the close command. I expect it to get to the closed position but if it doesn't after a period of time I want to flag an error.

I can create an "at" device
define a_timeout at +00:01:00 set timeout_error on
But if the move command succeeds then I need to cancel the "at". I know about the "delete" command but in my case there are multiple ways for the move to be initiated and if I issue the delete command and the "at" hasn't yet been created then it throws an error.

What I need is something like
IF (ifdef a_timeout) (delete a_timeout)
I also see there is a "sleep" and "cancel" command but this has the same problem.

I feel I must be missing something but have read the cmd ref from start to end without finding anything suitable.

Can anyone point me in the right direction or provide me with some examples of code using timeouts?

Many thanks.

Offline Beta-User

  • Developer
  • Hero Member
  • ****
  • Beiträge: 19326
Antw:How to do timeouts in FHEM?
« Antwort #1 am: 02 Januar 2022, 17:31:13 »
Have a look at "watchdog".
Server: HP-T620@Debian 11, aktuelles FHEM@ConfigDB | CUL_HM (VCCU) | MQTT2: MiLight@ESP-GW, BT@OpenMQTTGw | MySensors: seriell, v.a. 2.3.1@RS485 | ZWave | ZigBee@deCONZ | SIGNALduino | MapleCUN | RHASSPY
svn: u.a MySensors, Weekday-&RandomTimer, Twilight,  div. attrTemplate-files

Offline jacko

  • New Member
  • *
  • Beiträge: 20
Antw:How to do timeouts in FHEM?
« Antwort #2 am: 03 Januar 2022, 09:48:15 »
Thanks, that's exactly what I need.
My concentration must have been waning by the time I got to the W commands  :o

Offline Beta-User

  • Developer
  • Hero Member
  • ****
  • Beiträge: 19326
Antw:How to do timeouts in FHEM?
« Antwort #3 am: 03 Januar 2022, 09:57:07 »
You are welcome :) .

Some additional remarks:
- have also a look at the "defmod" command;
- Despite "IF" seems to easen FHEM useage, I'd recommend to use "pure Perl" (lowercase "if"). To my own experience, typing some more code and Perl-Braces pays off somewhen in time;
- there's also an option called "named sleep". "help cancel" (and "help sleep") should give some more info about that.
Server: HP-T620@Debian 11, aktuelles FHEM@ConfigDB | CUL_HM (VCCU) | MQTT2: MiLight@ESP-GW, BT@OpenMQTTGw | MySensors: seriell, v.a. 2.3.1@RS485 | ZWave | ZigBee@deCONZ | SIGNALduino | MapleCUN | RHASSPY
svn: u.a MySensors, Weekday-&RandomTimer, Twilight,  div. attrTemplate-files

 

decade-submarginal