Time comparison

Begonnen von @lex99, 18 Oktober 2017, 23:08:54

Vorheriges Thema - Nächstes Thema



My perl used to work OK until recently when comparing times, using (sunrise_abs()) >("06:00:00") (not sure about the exact syntax I used)
Then it started to output an error recently (following an update I did on FHEM). 
I then switched to using the time_str2num function, but it won't work - what am I doing wrong - see below ?

2017.10.18 23:01:58 1: PERL WARNING: Use of uninitialized value in numeric gt (>) at (eval 341) line 1.
2017.10.18 23:01:58 3: eval: {if (time_str2num(sunrise_abs()) > time_str2num("06:00:00")) {fhem("set 0_SpotsExt_Entree on-until {sunrise()}" ) } }

Thanks !


time_str2num needs a full timestamp with date.

Try these in command field in FHEMWEB:
{time_str2num("06:00:00")} => Empty
{time_str2num("2017-01-01 06:00:00")} => 1483246800
Pi 3B, Alexa, CUL868+Selbstbau 1/2λ-Dipol-Antenne, USB Optolink / Vitotronic, Debmatic und HM / HmIP Komponenten, Rademacher Duofern Jalousien, Fritz!Dect Thermostaten, Proteus


I finally solved the problem using the isday() function:

*06:00 {if (!(isday())) {fhem("set 0_SpotsExt_Entree on-until {sunrise()}" ) } }

Summary: if it is not daytime (yet) at 06:00, then I put ON the spots until sunrise.

Thanks for your help.