How to do timeouts in FHEM?

Begonnen von jacko, 02 Januar 2022, 17:13:36

Vorheriges Thema - Nächstes Thema

jacko

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.

Beta-User

Server: HP-elitedesk@Debian 12, 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

jacko

Thanks, that's exactly what I need.
My concentration must have been waning by the time I got to the W commands  :o

Beta-User

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-elitedesk@Debian 12, 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