[Gelöst] - DOIF - Aktion nur ausführen, wenn innerhalb von Zeitspanne

Begonnen von cs301, 10 Juni 2021, 22:18:13

Vorheriges Thema - Nächstes Thema

cs301

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

cs301

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.

xenos1984


Frank_Huber

[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.

cs301

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  :)