Hallo zusammen,
ich schalte bei mir in der Küche die Lichter über einen dummy (dum.10.EG.ku.WS.LichtKomplett) automatisch nach einiger Zeit (wait 30) aus, wenn kein Bewegung (EG.ku.BMK.Kueche_Motion:motion) erkannt wird.
Das DOIF dazu:
Internals:
CFGFN
DEF ([EG.ku.BMK.Kueche_Motion:motion] eq "off")
(set dum.10.EG.ku.WS.LichtKomplett off)
NAME doif.10.EG.ku.WS.LichtKomplett
NR 1257
NTFY_ORDER 50-doif.10.EG.ku.WS.LichtKomplett
STATE cmd_1
TYPE DOIF
Readings:
2016-10-19 00:59:45 Device EG.ku.BMK.Kueche_Motion
2016-10-19 01:00:15 cmd 1
2016-10-19 01:00:15 cmd_event EG.ku.BMK.Kueche_Motion
2016-10-19 01:00:15 cmd_nr 1
2016-10-19 00:59:45 e_EG.ku.BMK.Kueche_Motion_motion off
2016-10-19 01:00:15 state cmd_1
2016-10-19 01:00:15 wait_timer no timer
Condition:
0 ReadingValDoIf($hash,'EG.ku.BMK.Kueche_Motion','motion','','',AttrVal($hash->{NAME},'notexist',undef)) eq "off"
Devices:
0 EG.ku.BMK.Kueche_Motion
all EG.ku.BMK.Kueche_Motion
Do:
0:
0 set dum.10.EG.ku.WS.LichtKomplett off
1:
Helper:
event reading: off,motion: off,logstate: motion
globalinit 1
last_timer 0
sleepdevice EG.ku.BMK.Kueche_Motion
sleepsubtimer -1
sleeptimer -1
timerdev EG.ku.BMK.Kueche_Motion
timerevent reading: off,motion: off,logstate: motion
triggerDev EG.ku.BMK.Kueche_Motion
timerevents:
reading: off
motion: off
logstate: motion
timereventsState:
reading: off
motion: off
logstate: motion
triggerEvents:
reading: off
motion: off
logstate: motion
triggerEventsState:
reading: off
motion: off
logstate: motion
Internals:
Itimer:
Readings:
0 EG.ku.BMK.Kueche_Motion:motion
all EG.ku.BMK.Kueche_Motion:motion
Regexp:
0:
All:
State:
Trigger:
Attributes:
wait 30
Das funktioniert auch so, wie ich will.
Jetzt möchte ich gerne, wenn das Licht durch dieses DOIF ausgeschaltet wurde und erneut Bewegung erkannt wird, wieder angeschaltet wird.
Wenn aber jemand das Licht manuell ausgemacht hat, soll es nicht mehr automatisch eingeschaltet werden.
Kann mir jemand nen Tipp geben, wie ich das im sinnvollsten / einfachsten löse?
Geht das ggf. im DOIF und ich finde dafür einfach nur das Beispiel / die Vorlage nicht?
Danke und Grüße
Christian
Da DOIF ja wie eine State Machine arbeitet, also immer in einem bestimmten Zustand ist, könnte man das ja mit abfragen.
Da ich nicht weiß was für Events von deinem Lichtschalter kommen mal in Pseudo Code:
DOIF ([Lichtschalterevent:"on"])
(set Licht aus) // Zeitverzögert über wait attribute
DOELSIF ([Motionevent:"motionDetected"] and [$SELF:cmd_nr] == 1 and [Licht:state] eq "off")
(set Licht an)
DOELSEIF ([Lichtschalterevent:"off"])
// Hier wird nichts ausgeführt. Dient nur dazu, dass wir nicht mehr in CMD1 hängen und somit durch Bewegung kein Licht mehr angeht
Zitat von: Christian Uhlmann am 19 Oktober 2016, 01:07:59Kann mir jemand nen Tipp geben, wie ich das im sinnvollsten / einfachsten löse?
Ich habe es so (https://forum.fhem.de/index.php/topic,52225.0.html) gelöst.
Ist seit dem unauffällig im Einsatz.