FHEM Forum

FHEM => Anfängerfragen => Thema gestartet von: cs301 am 10 Juni 2021, 22:18:13

Titel: [Gelöst] - DOIF - Aktion nur ausführen, wenn innerhalb von Zeitspanne
Beitrag von: cs301 am 10 Juni 2021, 22:18:13
Moin,

ich bräuchte mal wieder Eure Hilfe und einen Tipp...  :)

Aufgabe: Kodilicht soll nur in der angegebenen Zeitspanne schalten. Das funktioniert so ungefähr auch.
Problem: Wenn Kodi schon im "Gestoppt/Pause" Zustand ist UND dann die Zeit zutrifft, wird logischerweise geschaltet. Es soll aber nur geschaltet werden, wenn sich innerhalb der Zeitspanne der Zustand ändert.

Gibt es eine Möglichkeit dieses Verhalten umzusetzen? z.B. so ähnlich wie bei ioBroker das OnResume oder HA from/to, wenn von Pause nach Play gewechselt wird.
KODI bietet hier solche Readings nicht an.


defmod kodilicht DOIF (\
[KODI:playStatus] eq "playing" and [KODI:currentMedia] ne "" and\
(\
  [KODI:type] eq "episode" or \
  [KODI:type] eq "movie" or\
  [KODI:type] eq "unknown" \
)\
)  \
(set MQTT2_Lampe off,set MQTT2_TVLED off, set MQTT2_WLED off)\
DOELSEIF (\
[KODI:playStatus] eq "playing" and [KODI:type] eq "song"\
)\
(set MQTT2_WLED on)\
DOELSEIF (\
[KODI:playStatus] eq "paused" and [KODI:currentMedia] ne "" and \
(\
  [KODI:type] eq "episode" or \
  [KODI:type] eq "movie" or\
  [KODI:type] eq "unknown"\
) and [21:00-06:00]\
)\
(set MQTT2_TVLED on) \
  \
DOELSEIF (\
[KODI:playStatus] eq "stopped" and [KODI:currentMedia] ne "" and\
(\
  [KODI:type] eq "episode" or \
  [KODI:type] eq "movie" or\
  [KODI:type] eq "unknown"\
) and [21:00-06:00]\
) \
(set MQTT2_Lampe on,set MQTT2_TVLED off)\
\



Vielen Dank
Titel: Antw:DOIF - Aktion nur ausführen, wenn Status innerhalb von Zeitspanne wechselt
Beitrag von: cs301 am 10 Juni 2021, 23:29:10
Ne Tüte Nüsse und ein Bier später... scheinbar die Lösung.

ein zusätzliches Notify
defmod notify_KODI_Licht notify KODI:playStatus:.* set dummy_KODI_playStatus on-for-timer 1

und ein Dummy.
defmod dummy_KODI_playStatus dummy
attr dummy_KODI_playStatus setList on off


in kodilicht zusätzlich mit UND abgefragt
defmod kodilicht DOIF (\
[KODI:playStatus] eq "playing" and [KODI:currentMedia] ne "" and\
(\
  [KODI:type] eq "episode" or \
  [KODI:type] eq "movie" or\
  [KODI:type] eq "unknown" \
) and [dummy_KODI_playStatus]\
)  \
(set MQTT2_Lampe off,set MQTT2_TVLED off, set MQTT2_WLED off)\
DOELSEIF (\
[KODI:playStatus] eq "playing" and [KODI:type] eq "song"\
)\
(set MQTT2_WLED on)\
DOELSEIF (\
[KODI:playStatus] eq "paused" and [KODI:currentMedia] ne "" and \
(\
  [KODI:type] eq "episode" or \
  [KODI:type] eq "movie" or\
  [KODI:type] eq "unknown"\
) and [21:00-06:00] and [dummy_KODI_playStatus]\
)\
(set MQTT2_TVLED on) \
  \
DOELSEIF (\
[KODI:playStatus] eq "stopped" and [KODI:currentMedia] ne "" and\
(\
  [KODI:type] eq "episode" or \
  [KODI:type] eq "movie" or\
  [KODI:type] eq "unknown"\
) and [21:00-06:00] and [dummy_KODI_playStatus]\
) \
(set MQTT2_Lampe on,set MQTT2_TVLED off)\
\


nicht vergessen
attr KODI event-on-change-reading playStatus


bisher funktioniert es wie erhofft.
Titel: Antw:DOIF - Aktion nur ausführen, wenn Status innerhalb von Zeitspanne wechselt
Beitrag von: xenos1984 am 11 Juni 2021, 06:26:16
Warum denn so kompliziert?

http://fhem.de/commandref_DE.html#DOIF_Zeitintervalle_Readings_und_Status_ohne_Trigger

Einfach aus dem


[21:00-06:00]


im ursprünglichen DOIF ein


[?21:00-06:00]


und gut ist.
Titel: Antw:DOIF - Aktion nur ausführen, wenn Status innerhalb von Zeitspanne wechselt
Beitrag von: Frank_Huber am 11 Juni 2021, 08:54:14
[KODI:playStatus] eq "playing"
Den hier von "Zustand" auf "Event" unbauen hätte auch gereicht.

Ich würde aber auch wie von Xenos vorgeschlagen die Zeit als nicht triggernd machen.
Titel: Antw:DOIF - Aktion nur ausführen, wenn Status innerhalb von Zeitspanne wechselt
Beitrag von: cs301 am 11 Juni 2021, 12:21:51
Zitat von: xenos1984 am 11 Juni 2021, 06:26:16
Warum denn so kompliziert?
...

im ursprünglichen DOIF ein


[?21:00-06:00]


und gut ist.

:o so einfach?! Wieder was gelernt. Ich sollte die Commandref wirklich genauer lesen...

Vielen Dank  :)