MQTT_DEVICE, eventMap & SetExtensions: on-till {sunrise("REAL")}

Begonnen von p2k, 05 August 2018, 14:35:23

Vorheriges Thema - Nächstes Thema

p2k

Hi,

ich habe mich durch die Threads https://forum.fhem.de/index.php/topic,82240.0.html und https://forum.fhem.de/index.php?topic=84561.0 durchgelesen und möchte mich sehr bei allen Beteiligten bedanken, dass FHEM so super funktioniert.

Ich habe auf einer OBI WLAN Steckdose ESP Easy Mega laufen und kann nun via MQTT schalten.

Laut CommandRef für 'SET' (https://fhem.de/commandref.html#set) sollte bei on-till, wenn die End-Zeit schon überschritten ist, kein Einschalten erfolgen:

ZitatNote: on-till is not active, if the specified time is after the current time...

Leider funktioniert das bei mir aber nicht. Es wird eingeschaltet und das Ausschalten wird für morgen früh aktiviert.

Internals:
   CFGFN     
   COMMAND    set ObiSocketGang1 on-till {sunrise("REAL")}
   DEF        *14:26 set ObiSocketGang1 on-till {sunrise("REAL")}
   NAME       Gang1MorgenLichtTest2
   NR         1235
   PERIODIC   yes
   RELATIVE   no
   REP        -1
   STATE      Next: 14:26:00
   TIMESPEC   14:26
   TRIGGERTIME 1533558360
   TRIGGERTIME_FMT 2018-08-06 14:26:00
   TYPE       at
   READINGS:
     2018-08-05 14:26:00   state           Next: 14:26:00
Attributes:
   room       Zeitschaltuhr
   verbose    5


Internals:
   IODev      pi173MQTT
   NAME       ObiSocketGang1
   NR         78
   STATE      off
   TYPE       MQTT_DEVICE
   READINGS:
     2018-08-05 14:32:37   Status          0
     2018-08-05 14:26:37   state           event,powerOff
     2018-08-05 14:32:37   transmission-state incoming publish received
   message_ids:
   publishSets:
     :
       topic      /ESP_Easy_GangLicht/cmd
       values:
         event,powerOn
         event,powerOff
   sets:
     event,powerOff
     event,powerOn
   subscribe:
     /ESP_Easy_GangLicht/store/powerState
   subscribeExpr:
     ^\/ESP_Easy_GangLicht\/store\/powerState$
   subscribeQos:
     /ESP_Easy_GangLicht/store/powerState 0
   subscribeReadings:
     /ESP_Easy_GangLicht/store/powerState:
       cmd       
       name       Status
Attributes:
   IODev      pi173MQTT
   devStateIcon event,powerOn:rc_GREEN:event,powerOff event,powerOff:rc_RED:event,powerOn
   eventMap   {dev=>{'event,powerOn'=>'on', 'event,powerOff'=>'off'}, usr=>{'^on$'=>'event,powerOn', '^off$'=>'event,powerOff'}, fw=>{'^on$'=>'on', '^off$'=>'off'}}
   icon       hue_filled_outlet
   publishSet event,powerOn event,powerOff /ESP_Easy_GangLicht/cmd
   room       MQTT,Zeitschaltuhr
   subscribeReading_Status /ESP_Easy_GangLicht/store/powerState
   useSetExtensions 1
   verbose    5
   webCmd     on:off


Logfile:
2018.08.05 14:26:00 5: exec at command Gang1MorgenLichtTest2
2018.08.05 14:26:00 5: calling SetExtensions(...) for on-till
2018.08.05 14:26:00 5: redefine at command Gang1MorgenLichtTest2 as *14:26 set ObiSocketGang1 on-till {sunrise("REAL")}
2018.08.05 14:26:00 5: publish received for /ESP_Easy_GangLicht/store/powerState, 1
2018.08.05 14:26:00 5: calling readingsSingleUpdate(ObiSocketGang1,Status,1,1)
2018.08.05 14:26:00 5: publish received for /ESP_Easy_GangLicht/store/powerState, 1



Hat wer eine Idee, was ich falsch gemacht habe? FHEM ist auf dem PatchStand von gestern.

danke
lg
Philipp

p2k

Mit etwas Debug in SetExtensions.pm bin ich dahinter gekommen, dass der Sunrise in mehr als 24 Stunden ist:

2018.08.06 09:33:00 5: exec at command Gang1MorgenLichtTest2
2018.08.06 09:33:00 5: calling SetExtensions(...) for on-till
2018.08.06 09:33:00 4: on-till: hms_till: 29:44:47
2018.08.06 09:33:00 4: on-till: -till branch, hms_now: 09:33:00

Das gleiche Verhalten konnte ich feststellen, wenn ich meinem Dummy th_Licht

Internals:
   NAME       th_Licht
   NR         41
   STATE      on
   TYPE       dummy
   READINGS:
     2018-08-06 09:37:00   state           on
Attributes:
   room       Treppenhaus,Zeitschaltuhr
   setList    on off
   useSetExtensions 1
   verbose    5
   webCmd     on:off


auch bis zum Sonnenaufgang einschalte:

Internals:
   COMMAND    set th_Licht on-till {sunrise("REAL")}
   DEF        *09:37 set th_Licht on-till {sunrise("REAL")}
   NAME       th_Licht_Test
   NR         83
   PERIODIC   yes
   RELATIVE   no
   REP        -1
   STATE      Next: 09:37:00
   TIMESPEC   09:37
   TRIGGERTIME 1533627420
   TRIGGERTIME_FMT 2018-08-07 09:37:00
   TYPE       at
   READINGS:
     2018-08-06 09:37:00   state           Next: 09:37:00
Attributes:
   room       Zeitschaltuhr
   verbose    5


2018.08.06 09:37:00 5: exec at command th_Licht_Test
2018.08.06 09:37:00 4: on-till: hms_till: 29:44:47
2018.08.06 09:37:00 4: on-till: -till branch, hms_now: 09:37:00
2018.08.06 09:37:00 4: dummy set th_Licht on
2018.08.06 09:37:00 5: redefine at command th_Licht_Test as *09:37 set th_Licht on-till {sunrise("REAL")}


Ich hab das jetzt so gelöst, dass ich im [on|off]-till Zweig eine Abfrage eingebaut habe, ob die hms_till Zeit > 24:00:00 ist:

diff -u SetExtensions.pm_ORIG SetExtensions.pm
--- SetExtensions.pm_ORIG       2018-08-06 09:42:16.979742374 +0200
+++ SetExtensions.pm    2018-08-06 10:38:21.616221313 +0200
@@ -118,6 +118,12 @@
           "$cmd: won't switch as now ($hms_now) is later than $hms_till";
         return "";
       }
+
+      if("24:00:00" le $hms_till) {
+        Log3 $hash, 4,
+          "$cmd: won't switch as $hms_till is tomorrow";
+        return "";
+      }
     }
     SE_DoSet($name, $cmd1);
     CommandDefine(undef, "${name}_till at $hms_till set $name $cmd2");


@rudolfkoenig: Kannst du dir das bitte mal ansehen und eventuell einchecken. Würde meiner Meinung nach damit der Doku entsprechen.

Danke
Philipp

rudolfkoenig