Hauptmenü

DOIF-Syntax Nachfrage

Begonnen von andies, 12 September 2017, 08:38:15

Vorheriges Thema - Nächstes Thema

andies

Darf ich die Profis hier im Forum etwas fragen? Ich verstehe nicht, warum die nachfolgende Syntax nicht funktioniert:
defmod <devicename> DOIF ([07:00|AT] or [{sunset("HORIZON=-0.8",0,"07:10","10:00")}]) (set <device> on)

Werden bei sunset nicht Zeiten ausgegeben, die man direkt in DOIF nutzen kann?

PS Fehlermeldung
timer_01_c01 error: Wrong timespec 0.833")}: either HH:MM:SS or {perlcode}
FHEM 6.1 auf RaspPi3 (Raspbian:  6.1.21-v8+; Perl: v5.32.1)
SIGNALduino (433 MHz) und HM-UART (868 MHz), Sonoff, Blitzwolf, Somfy RTS, CAME-Gartentor, Volkszähler, Keyence-Sensor, Homematic-Sensoren und -thermostat, Ferraris-Zähler für Wasseruhr, Openlink-Nachbau Viessmann

CoolTux

#1
Meine Antwort war nach genauem hinschauen in den Treffern falsch. So sollte es eigentlich gehen wie Du geschrieben hast. Aber!


defmod <devicename> DOIF ([07:00|AT] or [{sunset("HORIZON=-0.8",0,"07:10","10:00")}]) (set <device> on)


Eventuell kommt er mit den 0.8 nicht klar und es geht nur ganze Werte
Du musst nicht wissen wie es geht! Du musst nur wissen wo es steht, wie es geht.
Support me to buy new test hardware for development: https://www.paypal.com/paypalme/MOldenburg
My FHEM Git: https://git.cooltux.net/FHEM/
Das TuxNet Wiki:
https://www.cooltux.net

kumue

wenn ich mir aber ein Beispiel aus dem Wiki anschaue, ist die sunset-Syntax von andies aber korrekt...oder der wiki-Eintrag ist falsch

# Gleiches Beispiel mit Eingabe der Höhe über Horizont als 1. Parameter:
{sunset("HORIZON=-6.0",0,"17:00","22:00")}
Ergebnis (als Beispiel):   19:59:22


CoolTux

Du musst nicht wissen wie es geht! Du musst nur wissen wo es steht, wie es geht.
Support me to buy new test hardware for development: https://www.paypal.com/paypalme/MOldenburg
My FHEM Git: https://git.cooltux.net/FHEM/
Das TuxNet Wiki:
https://www.cooltux.net

andies

#4
Also, ich bin mal ganz ausführlich. Das habe ich als Code
defmod Anwesenheitsgeraet DOIF (Value("Anwesenheit") eq "0") () DOELSEIF ([{sunset("HORIZON=-0.8",0,"15:33","21:00")}] or [07:10|AT] or [08:45|WE]) (set Sonoff on) DOELSEIF ([07:45|AT] or [09:05|WE] or [21:43]) (set Sonoff off)
und ein List gibt mir
Internals:
   CFGFN
   DEF        (Value("Anwesenheit") eq "0") () DOELSEIF ([{sunset("HORIZON=-0.8",0,"15:33","21:00")}] or [07:10|AT] or [08:45|WE]) (set Sonoff on) DOELSEIF ([07:45|AT] or [09:05|WE] or [21:43]) (set Sonoff off)
   NAME       Anwesenheit
   NR         249
   NTFY_ORDER 50-Anwesenheit
   STATE      initialized
   TYPE       DOIF
   READINGS:
     2017-09-12 08:59:37   cmd             0
     2017-09-11 21:43:00   cmd_event       timer_7
     2017-09-11 21:43:00   cmd_nr          2
     2017-09-12 08:59:37   state           initialized
     2017-09-12 08:41:45   timer_01_c01    13.09.2017 07:10:00|AT
     2017-09-12 08:59:37   timer_01_c02    12.09.2017 19:29:37
     2017-09-12 08:45:00   timer_02_c01    13.09.2017 08:45:00|WE
     2017-09-12 08:59:37   timer_02_c02    13.09.2017 07:10:00|AT
     2017-09-12 08:41:45   timer_03_c01    12.09.2017 19:29:37
     2017-09-12 08:59:37   timer_03_c02    13.09.2017 08:45:00|WE
     2017-09-12 06:50:43   timer_04_c01    error: Wrong timespec 0.833")}: either HH:MM:SS or {perlcode}
     2017-09-12 08:41:45   timer_04_c02    13.09.2017 07:45:00|AT
     2017-09-12 08:59:37   timer_04_c03    13.09.2017 07:45:00|AT
     2017-09-12 08:41:45   timer_05_c02    12.09.2017 09:05:00|WE
     2017-09-12 08:59:37   timer_05_c03    12.09.2017 09:05:00|WE
     2017-09-12 08:41:45   timer_06_c02    12.09.2017 21:43:00
     2017-09-12 08:59:37   timer_06_c03    12.09.2017 21:43:00
     2017-09-12 06:50:43   timer_07_c02    12.09.2017 21:43:00
   condition:
     0          Value("Anwesenheit") eq "0"
     1          DOIF_time_once($hash,0,$wday) or DOIF_time_once($hash,1,$wday,"AT") or DOIF_time_once($hash,2,$wday,"WE")
     2          DOIF_time_once($hash,3,$wday,"AT") or DOIF_time_once($hash,4,$wday,"WE") or DOIF_time_once($hash,5,$wday)
   days:
     1          AT
     2          WE
     3          AT
     4          WE
   devices:
   do:
     0:
       0
     1:
       0          set Sonoff on
     2:
       0          set Sonoff off
     3:
   helper:
     globalinit 1
     last_timer 6
     sleeptimer -1
   itimer:
   localtime:
     0          1505237377
     1          1505279400
     2          1505285100
     3          1505281500
     4          1505199900
     5          1505245380
   realtime:
     0          19:29:37
     1          07:10:00
     2          08:45:00
     3          07:45:00
     4          09:05:00
     5          21:43:00
   regexp:
     all:
   state:
     STATE:
   time:
     0          {sunset("HORIZON=-0.8",0,"15:33","21:00")}
     1          07:10:00
     2          08:45:00
     3          07:45:00
     4          09:05:00
     5          21:43:00
   timeCond:
     0          1
     1          1
     2          1
     3          2
     4          2
     5          2
   timer:
     0          0
     1          0
     2          0
     3          0
     4          0
     5          0
   timers:
     1           0  1  2
     2           3  4  5
   triggertime:
     1505199900:
       localtime  1505199900
       hash:
     1505237377:
       localtime  1505237377
       hash:
     1505245380:
       localtime  1505245380
       hash:
     1505279400:
       localtime  1505279400
       hash:
     1505281500:
       localtime  1505281500
       hash:
     1505285100:
       localtime  1505285100
       hash:

Da ist doch was falsch, oder irre ich mich?
FHEM 6.1 auf RaspPi3 (Raspbian:  6.1.21-v8+; Perl: v5.32.1)
SIGNALduino (433 MHz) und HM-UART (868 MHz), Sonoff, Blitzwolf, Somfy RTS, CAME-Gartentor, Volkszähler, Keyence-Sensor, Homematic-Sensoren und -thermostat, Ferraris-Zähler für Wasseruhr, Openlink-Nachbau Viessmann

kumue

hab mal deine syntax bei mir eingegeben und keine Fehlermeldung und auch weniger Timer..
Internals:
   CFGFN
   DEF        (Value("Anwesenheit") eq "0") () DOELSEIF ([{sunset("HORIZON=-0.8",0,"15:33","21:00")}] or [07:10|AT] or [08:45|WE]) (set Sonoff on) DOELSEIF ([07:45|AT] or [09:05|WE] or [21:43]) (set Sonoff off)
   NAME       Anwesenheitsgeraet
   NR         10840
   NTFY_ORDER 50-Anwesenheitsgeraet
   STATE      initialized
   TYPE       DOIF
   Helper:
     DBLOG:
       cmd:
         myDbLog:
           TIME       1505200321.33015
           VALUE      0
       state:
         myDbLog:
           TIME       1505200321.33015
           VALUE      initialized
   READINGS:
     2017-09-12 09:12:01   cmd             0
     2017-09-12 09:12:01   state           initialized
     2017-09-12 09:12:01   timer_01_c02    12.09.2017 19:37:30
     2017-09-12 09:12:01   timer_02_c02    13.09.2017 07:10:00|AT
     2017-09-12 09:12:01   timer_03_c02    13.09.2017 08:45:00|WE
     2017-09-12 09:12:01   timer_04_c03    13.09.2017 07:45:00|AT
     2017-09-12 09:12:01   timer_05_c03    13.09.2017 09:05:00|WE
     2017-09-12 09:12:01   timer_06_c03    12.09.2017 21:43:00
   condition:
     0          Value("Anwesenheit") eq "0"
     1          DOIF_time_once($hash,0,$wday) or DOIF_time_once($hash,1,$wday,"AT") or DOIF_time_once($hash,2,$wday,"WE")
     2          DOIF_time_once($hash,3,$wday,"AT") or DOIF_time_once($hash,4,$wday,"WE") or DOIF_time_once($hash,5,$wday)
   days:
     1          AT
     2          WE
     3          AT
     4          WE
   devices:
   do:
     0:
       0
     1:
       0          set Sonoff on
     2:
       0          set Sonoff off
     3:
   helper:
     globalinit 1
     last_timer 6
     sleeptimer -1
   itimer:
   localtime:
     0          1505237850
     1          1505279400
     2          1505285100
     3          1505281500
     4          1505286300
     5          1505245380
   realtime:
     0          19:37:30
     1          07:10:00
     2          08:45:00
     3          07:45:00
     4          09:05:00
     5          21:43:00
   regexp:
     all:
   state:
     STATE:
   time:
     0          {sunset("HORIZON=-0.8",0,"15:33","21:00")}
     1          07:10:00
     2          08:45:00
     3          07:45:00
     4          09:05:00
     5          21:43:00
   timeCond:
     0          1
     1          1
     2          1
     3          2
     4          2
     5          2
   timer:
     0          0
     1          0
     2          0
     3          0
     4          0
     5          0
   timers:
     1           0  1  2
     2           3  4  5
   triggertime:
     1505237850:
       localtime  1505237850
       hash:
     1505245380:
       localtime  1505245380
       hash:
     1505279400:
       localtime  1505279400
       hash:
     1505281500:
       localtime  1505281500
       hash:
     1505285100:
       localtime  1505285100
       hash:
     1505286300:
       localtime  1505286300
       hash:
Attributes:
   DbLogExclude .*

andies

Ich vermute jetzt, dass das ein Fehler aus einer früheren (falschen) Eingabe ist. Ich werde das mal am "lebenden" Objekt testen...


Gesendet von iPhone mit Tapatalk Pro
FHEM 6.1 auf RaspPi3 (Raspbian:  6.1.21-v8+; Perl: v5.32.1)
SIGNALduino (433 MHz) und HM-UART (868 MHz), Sonoff, Blitzwolf, Somfy RTS, CAME-Gartentor, Volkszähler, Keyence-Sensor, Homematic-Sensoren und -thermostat, Ferraris-Zähler für Wasseruhr, Openlink-Nachbau Viessmann

andies

Ich vermute jetzt, dass das ein Fehler aus einer früheren (falschen) Eingabe ist. Ich werde das mal am "lebenden" Objekt testen...


Gesendet von iPhone mit Tapatalk Pro
FHEM 6.1 auf RaspPi3 (Raspbian:  6.1.21-v8+; Perl: v5.32.1)
SIGNALduino (433 MHz) und HM-UART (868 MHz), Sonoff, Blitzwolf, Somfy RTS, CAME-Gartentor, Volkszähler, Keyence-Sensor, Homematic-Sensoren und -thermostat, Ferraris-Zähler für Wasseruhr, Openlink-Nachbau Viessmann

Damian

(Value("Anwesenheit") eq "0") allein in der Bedingung ist nicht sinnvoll, weil kein Trigger da ist. Dieser Zweig wird also nie getriggert und damit nie ausgewertet werden.
Programmierte FHEM-Module: DOIF-FHEM, DOIF-Perl, DOIF-uiTable, THRESHOLD, FHEM-Befehl: IF

andies

Zitat von: Damian am 12 September 2017, 10:22:20
(Value("Anwesenheit") eq "0") allein in der Bedingung ist nicht sinnvoll, weil kein Trigger da ist.
Ah, danke. Ich verstehe. Ich wollte das "übersichtlich" programmieren, aber so geht das wohl nicht. D.h. ich muss die Zeiten in die Bedingung hineintun, richtig? Dann ist das eine etwas verzweigte Bedingung mit and und or, aber geht wohl nicht anders.
FHEM 6.1 auf RaspPi3 (Raspbian:  6.1.21-v8+; Perl: v5.32.1)
SIGNALduino (433 MHz) und HM-UART (868 MHz), Sonoff, Blitzwolf, Somfy RTS, CAME-Gartentor, Volkszähler, Keyence-Sensor, Homematic-Sensoren und -thermostat, Ferraris-Zähler für Wasseruhr, Openlink-Nachbau Viessmann

Otto123

#10
Hi,

aber ([Anwesenheit] eq "0") wäre vom Sinn her das Gleiche und wird getriggert wenn Anwesenheit von irgendetwas nach "0" wechselt. Ist es nicht sogar genau das was Du willst?

Die FHEM Funktion Value("Anwesenheit") entspricht doch im "set magic" -> [Anwesenheit:state] und im DOIF -> [Anwesenheit]

-> https://fhem.de/commandref_DE.html#perl
-> https://fhem.de/commandref_DE.html#set
-> https://fhem.de/commandref_DE.html#DOIF_Lesbarkeit_der_Definitionen

Gruß Otto
Viele Grüße aus Leipzig  ⇉  nächster Stammtisch an der Lindennaundorfer Mühle
RaspberryPi B B+ B2 B3 B3+ ZeroW,HMLAN,HMUART,Homematic,Fritz!Box 7590,WRT3200ACS-OpenWrt,Sonos,VU+,Arduino nano,ESP8266,MQTT,Zigbee,deconz

andies

Nein,  das war leider wirklich anders gemeint. Ich will einmal einen Schalter umlegen (einmal im Monat zB) und dann sollen an jedem Tag diese Lichtorgelspiele laufen. Das würde, glaube ich, nicht laufen, weil die Bedingung von mir täglich geprüft werden müsste.


Gesendet von iPhone mit Tapatalk Pro
FHEM 6.1 auf RaspPi3 (Raspbian:  6.1.21-v8+; Perl: v5.32.1)
SIGNALduino (433 MHz) und HM-UART (868 MHz), Sonoff, Blitzwolf, Somfy RTS, CAME-Gartentor, Volkszähler, Keyence-Sensor, Homematic-Sensoren und -thermostat, Ferraris-Zähler für Wasseruhr, Openlink-Nachbau Viessmann

Otto123

#12
Dann hätte ich diese "übersichtliche" Idee für Dich:
defmod Anwesenheitsgeraet DOIF (([{sunset("HORIZON=-0.8",0,"15:33","21:00")}-21:43] or [07:10-07:45|AT] or [08:45-09:05|WE]) and [Anwesenheit] eq "0") (set Sonoff on) DOELSE (set Sonoff off)
Viele Grüße aus Leipzig  ⇉  nächster Stammtisch an der Lindennaundorfer Mühle
RaspberryPi B B+ B2 B3 B3+ ZeroW,HMLAN,HMUART,Homematic,Fritz!Box 7590,WRT3200ACS-OpenWrt,Sonos,VU+,Arduino nano,ESP8266,MQTT,Zigbee,deconz

andies

Vielen Dank für die Hilfe! Ich will so etwas wie einen Anwesenheitssimulator haben. Der soll dann (fortwährend) auslösen, wenn ich nicht da bin und das vorab entsprechend eingeschaltet habe. Geht das damit?


Gesendet von iPhone mit Tapatalk Pro
FHEM 6.1 auf RaspPi3 (Raspbian:  6.1.21-v8+; Perl: v5.32.1)
SIGNALduino (433 MHz) und HM-UART (868 MHz), Sonoff, Blitzwolf, Somfy RTS, CAME-Gartentor, Volkszähler, Keyence-Sensor, Homematic-Sensoren und -thermostat, Ferraris-Zähler für Wasseruhr, Openlink-Nachbau Viessmann

andies

Ja, das geht. Super - nochmals danke!!


Gesendet von iPhone mit Tapatalk Pro
FHEM 6.1 auf RaspPi3 (Raspbian:  6.1.21-v8+; Perl: v5.32.1)
SIGNALduino (433 MHz) und HM-UART (868 MHz), Sonoff, Blitzwolf, Somfy RTS, CAME-Gartentor, Volkszähler, Keyence-Sensor, Homematic-Sensoren und -thermostat, Ferraris-Zähler für Wasseruhr, Openlink-Nachbau Viessmann