[ASC] [DOIF] variable Rolladenschließzeiten abhängig von HOME STATE

Begonnen von Stephan1965, 16 März 2023, 09:23:19

Vorheriges Thema - Nächstes Thema

Stephan1965

Hallo liebes Forum,
ich möchte gerne Folgendes umsetzen:

Die Rollläden im Erdgeschoß sollen abends je nach Abwesenheitsstatus der Bewohner zu unterschiedlichen Zeiten schließen. Wenn die Bewohner zuhause sind, soll in den jeweiligen Rollladen das attr Rollo_xxx ASC_AutoAstroModeEvening CIVIL gesetzt sein und die Rollläden schließen später. Bei Abwesenheit der Bewohner sollen die genannten Rollläden etwas früher schließen -> attr Rollo_xxx ASC_AutoAstroModeEvening REAL.

Ich habe das mit einem DOIF umgesetzt:


Internals:
   DEF        ## Jemand ist zuhause
(([GBS13] ne "absent") and ([GBS13] ne "gone"))
(attr Rollo_WoZi_SF ASC_AutoAstroModeEvening CIVIL;
  attr Rollo_WoZi_SF ASC_AutoAstroModeMorning CIVIL;
  attr Rollo_Eingangsflur ASC_AutoAstroModeEvening CIVIL;
  attr Rollo_Eingangsflur ASC_AutoAstroModeMorning CIVIL;
  attr Rollo_WoZi_TF ASC_AutoAstroModeEvening CIVIL;
  attr Rollo_WoZi_TF ASC_AutoAstroModeMorning CIVIL;
  attr Rollo_WoZi_TT ASC_AutoAstroModeEvening CIVIL;
  attr Rollo_WoZi_TT ASC_AutoAstroModeMorning CIVIL;
  set ASControl renewAllTimer;
  save)
##
## Keiner zuhause
DOELSEIF
(([GBS13] eq "absent") or ([GBS13] eq "gone"))
    (attr Rollo_WoZi_SF ASC_AutoAstroModeEvening REAL;
  attr Rollo_WoZi_SF ASC_AutoAstroModeMorning REAL;
  attr Rollo_Eingangsflur ASC_AutoAstroModeEvening REAL;
  attr Rollo_Eingangsflur ASC_AutoAstroModeMorning REAL;
  attr Rollo_WoZi_TF ASC_AutoAstroModeEvening REAL;
  attr Rollo_WoZi_TF ASC_AutoAstroModeMorning REAL;
  attr Rollo_WoZi_TT ASC_AutoAstroModeEvening REAL;
  attr Rollo_WoZi_TT ASC_AutoAstroModeMorning REAL;
     set ASControl renewAllTimer;
  save)
   FUUID      5f4e7cf0-f33f-cd59-cdd2-b290879c9f885f2f
   MODEL      FHEM
   NAME       d_ASC_Anwesenheit
   NOTIFYDEV  GBS13,global
   NR         362
   NTFY_ORDER 50-d_ASC_Anwesenheit
   STATE      cmd_1
   TYPE       DOIF
   VERSION    27298 2023-03-05 15:15:00
   eventCount 792
   READINGS:
     2023-03-16 09:05:06   Device          GBS13
     2023-03-15 22:03:43   cmd             1
     2023-03-15 22:03:43   cmd_event       GBS13
     2023-03-15 22:03:43   cmd_nr          1
     2023-03-16 09:05:06   e_GBS13_STATE   home
     2020-11-30 09:27:15   mode            enabled
     2023-03-15 22:03:43   state           cmd_1
   Regex:
     accu:
     bar:
     barAvg:
     collect:
     cond:
       GBS13:
         0:
           &STATE     ^GBS13$
         1:
           &STATE     ^GBS13$
   attr:
     cmdState:
     wait:
     waitdel:
   condition:
     0          (::InternalDoIf($hash,'GBS13','STATE') ne "absent") and (::InternalDoIf($hash,'GBS13','STATE') ne "gone")
     1          (::InternalDoIf($hash,'GBS13','STATE') eq "absent") or (::InternalDoIf($hash,'GBS13','STATE') eq "gone")
   do:
     0:
       0          attr Rollo_WoZi_SF ASC_AutoAstroModeEvening CIVIL;   attr Rollo_WoZi_SF ASC_AutoAstroModeMorning CIVIL;   attr Rollo_Eingangsflur ASC_AutoAstroModeEvening CIVIL;   attr Rollo_Eingangsflur ASC_AutoAstroModeMorning CIVIL;   attr Rollo_WoZi_TF ASC_AutoAstroModeEvening CIVIL;   attr Rollo_WoZi_TF ASC_AutoAstroModeMorning CIVIL;   attr Rollo_WoZi_TT ASC_AutoAstroModeEvening CIVIL;   attr Rollo_WoZi_TT ASC_AutoAstroModeMorning CIVIL;   set ASControl renewAllTimer;   save
     1:
       0          attr Rollo_WoZi_SF ASC_AutoAstroModeEvening REAL;   attr Rollo_WoZi_SF ASC_AutoAstroModeMorning REAL;   attr Rollo_Eingangsflur ASC_AutoAstroModeEvening REAL;   attr Rollo_Eingangsflur ASC_AutoAstroModeMorning REAL;   attr Rollo_WoZi_TF ASC_AutoAstroModeEvening REAL;   attr Rollo_WoZi_TF ASC_AutoAstroModeMorning REAL;   attr Rollo_WoZi_TT ASC_AutoAstroModeEvening REAL;   attr Rollo_WoZi_TT ASC_AutoAstroModeMorning REAL;      set ASControl renewAllTimer;   save
     2:
   helper:
     NOTIFYDEV  GBS13,global
     event      residentsTotalRoommatesPresent: 2,residentsTotalRoommatesPresentDevs: rr_Birgit,rr_Stephan,residentsTotalRoommatesPresentNames: Bewohner, Bewohner,residentsTotalRoommatesAbsent: 2,residentsTotalRoommatesAbsentDevs: rr_Leonie,rr_Sophie,residentsTotalRoommatesAbsentNames: Bewohner, Bewohner,residentsTotalPeoplePresent: 2,residentsTotalPeoplePresentDevs: rr_Birgit,rr_Stephan,residentsTotalPeoplePresentNames: Bewohner, Bewohner,residentsTotalPeopleAbsent: 2,residentsTotalPeopleAbsentDevs: rr_Leonie,rr_Sophie,residentsTotalPeopleAbsentNames: Bewohner, Bewohner,residentsTotalPresent: 2,residentsTotalPresentDevs: rr_Birgit,rr_Stephan,residentsTotalPresentNames: Bewohner, Bewohner,residentsTotalAbsent: 2,residentsTotalAbsentDevs: rr_Leonie,rr_Sophie,residentsTotalAbsentNames: Bewohner, Bewohner,residentsHome: 2,residentsHomeDevs: rr_Birgit,rr_Stephan,residentsHomeNames: Bewohner, Bewohner,residentsAbsent: 0,residentsAbsentDevs: -,residentsAbsentNames: -,durTimerPresence: 11:01:23,lastActivity: home,lastActivityBy: Bewohner,lastActivityByDev: rr_Stephan
     globalinit 1
     last_timer 0
     sleeptimer -1
     timerdev   GBS13
     timerevent residentsTotalRoommatesPresent: 2,residentsTotalRoommatesPresentDevs: rr_Birgit,rr_Stephan,residentsTotalRoommatesPresentNames: Bewohner, Bewohner,residentsTotalRoommatesAbsent: 2,residentsTotalRoommatesAbsentDevs: rr_Leonie,rr_Sophie,residentsTotalRoommatesAbsentNames: Bewohner, Bewohner,residentsTotalPeoplePresent: 2,residentsTotalPeoplePresentDevs: rr_Birgit,rr_Stephan,residentsTotalPeoplePresentNames: Bewohner, Bewohner,residentsTotalPeopleAbsent: 2,residentsTotalPeopleAbsentDevs: rr_Leonie,rr_Sophie,residentsTotalPeopleAbsentNames: Bewohner, Bewohner,residentsTotalPresent: 2,residentsTotalPresentDevs: rr_Birgit,rr_Stephan,residentsTotalPresentNames: Bewohner, Bewohner,residentsTotalAbsent: 2,residentsTotalAbsentDevs: rr_Leonie,rr_Sophie,residentsTotalAbsentNames: Bewohner, Bewohner,residentsHome: 2,residentsHomeDevs: rr_Birgit,rr_Stephan,residentsHomeNames: Bewohner, Bewohner,residentsAbsent: 0,residentsAbsentDevs: -,residentsAbsentNames: -,durTimerPresence: 11:01:23,lastActivity: home,lastActivityBy: Bewohner,lastActivityByDev: rr_Stephan
     triggerDev GBS13
     timerevents:
       residentsTotalRoommatesPresent: 2
       residentsTotalRoommatesPresentDevs: rr_Birgit,rr_Stephan
       residentsTotalRoommatesPresentNames: Bewohner, Bewohner
       residentsTotalRoommatesAbsent: 2
       residentsTotalRoommatesAbsentDevs: rr_Leonie,rr_Sophie
       residentsTotalRoommatesAbsentNames: Bewohner, Bewohner
       residentsTotalPeoplePresent: 2
       residentsTotalPeoplePresentDevs: rr_Birgit,rr_Stephan
       residentsTotalPeoplePresentNames: Bewohner, Bewohner
       residentsTotalPeopleAbsent: 2
       residentsTotalPeopleAbsentDevs: rr_Leonie,rr_Sophie
       residentsTotalPeopleAbsentNames: Bewohner, Bewohner
       residentsTotalPresent: 2
       residentsTotalPresentDevs: rr_Birgit,rr_Stephan
       residentsTotalPresentNames: Bewohner, Bewohner
       residentsTotalAbsent: 2
       residentsTotalAbsentDevs: rr_Leonie,rr_Sophie
       residentsTotalAbsentNames: Bewohner, Bewohner
       residentsHome: 2
       residentsHomeDevs: rr_Birgit,rr_Stephan
       residentsHomeNames: Bewohner, Bewohner
       residentsAbsent: 0
       residentsAbsentDevs: -
       residentsAbsentNames: -
       durTimerPresence: 11:01:23
       lastActivity: home
       lastActivityBy: Bewohner
       lastActivityByDev: rr_Stephan
     timereventsState:
       residentsTotalRoommatesPresent: 2
       residentsTotalRoommatesPresentDevs: rr_Birgit,rr_Stephan
       residentsTotalRoommatesPresentNames: Bewohner, Bewohner
       residentsTotalRoommatesAbsent: 2
       residentsTotalRoommatesAbsentDevs: rr_Leonie,rr_Sophie
       residentsTotalRoommatesAbsentNames: Bewohner, Bewohner
       residentsTotalPeoplePresent: 2
       residentsTotalPeoplePresentDevs: rr_Birgit,rr_Stephan
       residentsTotalPeoplePresentNames: Bewohner, Bewohner
       residentsTotalPeopleAbsent: 2
       residentsTotalPeopleAbsentDevs: rr_Leonie,rr_Sophie
       residentsTotalPeopleAbsentNames: Bewohner, Bewohner
       residentsTotalPresent: 2
       residentsTotalPresentDevs: rr_Birgit,rr_Stephan
       residentsTotalPresentNames: Bewohner, Bewohner
       residentsTotalAbsent: 2
       residentsTotalAbsentDevs: rr_Leonie,rr_Sophie
       residentsTotalAbsentNames: Bewohner, Bewohner
       residentsHome: 2
       residentsHomeDevs: rr_Birgit,rr_Stephan
       residentsHomeNames: Bewohner, Bewohner
       residentsAbsent: 0
       residentsAbsentDevs: -
       residentsAbsentNames: -
       durTimerPresence: 11:01:23
       lastActivity: home
       lastActivityBy: Bewohner
       lastActivityByDev: rr_Stephan
     triggerEvents:
       residentsTotalRoommatesPresent: 2
       residentsTotalRoommatesPresentDevs: rr_Birgit,rr_Stephan
       residentsTotalRoommatesPresentNames: Bewohner, Bewohner
       residentsTotalRoommatesAbsent: 2
       residentsTotalRoommatesAbsentDevs: rr_Leonie,rr_Sophie
       residentsTotalRoommatesAbsentNames: Bewohner, Bewohner
       residentsTotalPeoplePresent: 2
       residentsTotalPeoplePresentDevs: rr_Birgit,rr_Stephan
       residentsTotalPeoplePresentNames: Bewohner, Bewohner
       residentsTotalPeopleAbsent: 2
       residentsTotalPeopleAbsentDevs: rr_Leonie,rr_Sophie
       residentsTotalPeopleAbsentNames: Bewohner, Bewohner
       residentsTotalPresent: 2
       residentsTotalPresentDevs: rr_Birgit,rr_Stephan
       residentsTotalPresentNames: Bewohner, Bewohner
       residentsTotalAbsent: 2
       residentsTotalAbsentDevs: rr_Leonie,rr_Sophie
       residentsTotalAbsentNames: Bewohner, Bewohner
       residentsHome: 2
       residentsHomeDevs: rr_Birgit,rr_Stephan
       residentsHomeNames: Bewohner, Bewohner
       residentsAbsent: 0
       residentsAbsentDevs: -
       residentsAbsentNames: -
       durTimerPresence: 11:01:23
       lastActivity: home
       lastActivityBy: Bewohner
       lastActivityByDev: rr_Stephan
     triggerEventsState:
       residentsTotalRoommatesPresent: 2
       residentsTotalRoommatesPresentDevs: rr_Birgit,rr_Stephan
       residentsTotalRoommatesPresentNames: Bewohner, Bewohner
       residentsTotalRoommatesAbsent: 2
       residentsTotalRoommatesAbsentDevs: rr_Leonie,rr_Sophie
       residentsTotalRoommatesAbsentNames: Bewohner, Bewohner
       residentsTotalPeoplePresent: 2
       residentsTotalPeoplePresentDevs: rr_Birgit,rr_Stephan
       residentsTotalPeoplePresentNames: Bewohner, Bewohner
       residentsTotalPeopleAbsent: 2
       residentsTotalPeopleAbsentDevs: rr_Leonie,rr_Sophie
       residentsTotalPeopleAbsentNames: Bewohner, Bewohner
       residentsTotalPresent: 2
       residentsTotalPresentDevs: rr_Birgit,rr_Stephan
       residentsTotalPresentNames: Bewohner, Bewohner
       residentsTotalAbsent: 2
       residentsTotalAbsentDevs: rr_Leonie,rr_Sophie
       residentsTotalAbsentNames: Bewohner, Bewohner
       residentsHome: 2
       residentsHomeDevs: rr_Birgit,rr_Stephan
       residentsHomeNames: Bewohner, Bewohner
       residentsAbsent: 0
       residentsAbsentDevs: -
       residentsAbsentNames: -
       durTimerPresence: 11:01:23
       lastActivity: home
       lastActivityBy: Bewohner
       lastActivityByDev: rr_Stephan
   internals:
     all         GBS13:STATE
   perlblock:
   readings:
   trigger:
   uiState:
   uiTable:
Attributes:
   icon       helper_doif
   room       ASC



Folgendes Problem:
Wenn die Bewohner zwischen den Zeitpunkten von REAL und CIVIL das Haus verlassen, passiert nichts. Die Rollläden bleiben oben und gehen erst wieder runter, wenn jemand nach Hause kommt. Wie könnte ich das abfangen?

Wäre eine vom HomeStatus abhängige flexible Schließzeit eine Funktion, die in ASC implementiert werden könnte?

Viele Grüße
Stephan


gestein

Hallo Stephan,

wäre es nicht einfacher, in den Attributen für die Zeiten (ASC_Time_XX) eine perl-Funktion aufzurufen und dort unterschiedliche Zeiten zurückzugeben?

lg, Gerhard

Stephan1965

Hallo,
ich habe das jetzt so gelöst:
Internals:
   DEF        ## Keiner zuhause, aber abends zwischen den Schaltzeiten REAL und CIVIL
((([GBS13] eq "absent") or ([GBS13] eq "gone") )and [{sunset("REAL",0,"17:00","22:00")} - {sunset("CIVIL",0,"17:00","22:00")}])
    (attr Rollo_WoZi_SF ASC_AutoAstroModeEvening REAL;
     attr Rollo_WoZi_SF ASC_AutoAstroModeMorning REAL;
     attr Rollo_Eingangsflur ASC_AutoAstroModeEvening REAL;
     attr Rollo_Eingangsflur ASC_AutoAstroModeMorning REAL;
     attr Rollo_WoZi_TF ASC_AutoAstroModeEvening REAL;
     attr Rollo_WoZi_TF ASC_AutoAstroModeMorning REAL;
     attr Rollo_WoZi_TT ASC_AutoAstroModeEvening REAL;
     attr Rollo_WoZi_TT ASC_AutoAstroModeMorning REAL;
     set ASControl renewAllTimer;
set Rollo_Eingangsflur closed;
set Rollo_WoZi_SF closed;
set Rollo_WoZi_TF closed;
set Rollo_WoZi_TT closed;
save)
##
DOELSEIF
(([GBS13] ne "absent") and ([GBS13] ne "gone"))
    (attr Rollo_WoZi_SF ASC_AutoAstroModeEvening CIVIL;
     attr Rollo_WoZi_SF ASC_AutoAstroModeMorning CIVIL;
     attr Rollo_Eingangsflur ASC_AutoAstroModeEvening CIVIL;
     attr Rollo_Eingangsflur ASC_AutoAstroModeMorning CIVIL;
     attr Rollo_WoZi_TF ASC_AutoAstroModeEvening CIVIL;
     attr Rollo_WoZi_TF ASC_AutoAstroModeMorning CIVIL;
     attr Rollo_WoZi_TT ASC_AutoAstroModeEvening CIVIL;
     attr Rollo_WoZi_TT ASC_AutoAstroModeMorning CIVIL;
     set ASControl renewAllTimer;
     save)
##
## Keiner zuhause, nach CIVIL
DOELSEIF
(([GBS13] eq "absent") or ([GBS13] eq "gone"))
    (attr Rollo_WoZi_SF ASC_AutoAstroModeEvening REAL;
     attr Rollo_WoZi_SF ASC_AutoAstroModeMorning REAL;
     attr Rollo_Eingangsflur ASC_AutoAstroModeEvening REAL;
     attr Rollo_Eingangsflur ASC_AutoAstroModeMorning REAL;
     attr Rollo_WoZi_TF ASC_AutoAstroModeEvening REAL;
     attr Rollo_WoZi_TF ASC_AutoAstroModeMorning REAL;
     attr Rollo_WoZi_TT ASC_AutoAstroModeEvening REAL;
     attr Rollo_WoZi_TT ASC_AutoAstroModeMorning REAL;
     set ASControl renewAllTimer;
     save)
   FUUID      5f4e7cf0-f33f-cd59-cdd2-b290879c9f885f2f
   MODEL      FHEM
   NAME       d_ASC_Anwesenheit
   NOTIFYDEV  GBS13,global
   NR         361
   NTFY_ORDER 50-d_ASC_Anwesenheit
   STATE      cmd_2
   TYPE       DOIF
   VERSION    27298 2023-03-05 15:15:00
   eventCount 78
   READINGS:
     2023-03-18 13:38:51   Device          GBS13
     2023-03-18 13:28:45   cmd             2
     2023-03-18 13:28:45   cmd_event       GBS13
     2023-03-18 13:28:45   cmd_nr          2
     2023-03-18 13:38:51   e_GBS13_STATE   home
     2023-03-18 13:28:38   mode            enabled
     2023-03-18 13:28:45   state           cmd_2
     2023-03-18 13:28:38   timer_01_c01    18.03.2023 18:34:41
     2023-03-18 13:28:38   timer_02_c01    18.03.2023 19:12:44
   Regex:
     accu:
     bar:
     barAvg:
     collect:
     cond:
       GBS13:
         0:
           &STATE     ^GBS13$
         1:
           &STATE     ^GBS13$
         2:
           &STATE     ^GBS13$
   attr:
     cmdState:
     wait:
     waitdel:
   condition:
     0          ((::InternalDoIf($hash,'GBS13','STATE') eq "absent") or (::InternalDoIf($hash,'GBS13','STATE') eq "gone") )and ::DOIF_time($hash,0,1,$wday,$hms)
     1          (::InternalDoIf($hash,'GBS13','STATE') ne "absent") and (::InternalDoIf($hash,'GBS13','STATE') ne "gone")
     2          (::InternalDoIf($hash,'GBS13','STATE') eq "absent") or (::InternalDoIf($hash,'GBS13','STATE') eq "gone")
   days:
   do:
     0:
       0          attr Rollo_WoZi_SF ASC_AutoAstroModeEvening REAL;      attr Rollo_WoZi_SF ASC_AutoAstroModeMorning REAL;      attr Rollo_Eingangsflur ASC_AutoAstroModeEvening REAL;      attr Rollo_Eingangsflur ASC_AutoAstroModeMorning REAL;      attr Rollo_WoZi_TF ASC_AutoAstroModeEvening REAL;      attr Rollo_WoZi_TF ASC_AutoAstroModeMorning REAL;      attr Rollo_WoZi_TT ASC_AutoAstroModeEvening REAL;      attr Rollo_WoZi_TT ASC_AutoAstroModeMorning REAL;      set ASControl renewAllTimer; set Rollo_Eingangsflur closed; set Rollo_WoZi_SF closed; set Rollo_WoZi_TF closed; set Rollo_WoZi_TT closed; save
     1:
       0          attr Rollo_WoZi_SF ASC_AutoAstroModeEvening CIVIL;      attr Rollo_WoZi_SF ASC_AutoAstroModeMorning CIVIL;      attr Rollo_Eingangsflur ASC_AutoAstroModeEvening CIVIL;      attr Rollo_Eingangsflur ASC_AutoAstroModeMorning CIVIL;      attr Rollo_WoZi_TF ASC_AutoAstroModeEvening CIVIL;      attr Rollo_WoZi_TF ASC_AutoAstroModeMorning CIVIL;      attr Rollo_WoZi_TT ASC_AutoAstroModeEvening CIVIL;      attr Rollo_WoZi_TT ASC_AutoAstroModeMorning CIVIL;      set ASControl renewAllTimer;      save
     2:
       0          attr Rollo_WoZi_SF ASC_AutoAstroModeEvening REAL;      attr Rollo_WoZi_SF ASC_AutoAstroModeMorning REAL;      attr Rollo_Eingangsflur ASC_AutoAstroModeEvening REAL;      attr Rollo_Eingangsflur ASC_AutoAstroModeMorning REAL;      attr Rollo_WoZi_TF ASC_AutoAstroModeEvening REAL;      attr Rollo_WoZi_TF ASC_AutoAstroModeMorning REAL;      attr Rollo_WoZi_TT ASC_AutoAstroModeEvening REAL;      attr Rollo_WoZi_TT ASC_AutoAstroModeMorning REAL;      set ASControl renewAllTimer;      save
     3:
   helper:
     NOTIFYDEV  GBS13,global
     event      durTimerPresence_cr: 1449,durTimerPresence: 24:09:03
     globalinit 1
     last_timer 2
     sleeptimer -1
     timerdev   GBS13
     timerevent durTimerPresence_cr: 1449,durTimerPresence: 24:09:03
     triggerDev GBS13
     timerevents:
       durTimerPresence_cr: 1449
       durTimerPresence: 24:09:03
     timereventsState:
       durTimerPresence_cr: 1449
       durTimerPresence: 24:09:03
     triggerEvents:
       durTimerPresence_cr: 1449
       durTimerPresence: 24:09:03
     triggerEventsState:
       durTimerPresence_cr: 1449
       durTimerPresence: 24:09:03
   internals:
     all         GBS13:STATE
   interval:
     0          -1
     1          0
   intervalfunc:
   localtime:
     0          1679160881
     1          1679163164
   readings:
   realtime:
     0          18:34:41
     1          19:12:44
   time:
     0          {sunset("REAL",0,"17:00","22:00")}
     1          {sunset("CIVIL",0,"17:00","22:00")}
   timeCond:
     0          0
     1          0
   timer:
     0          0
     1          0
   timers:
     0           0  1
   trigger:
   triggertime:
     1679160881:
       localtime  1679160881
       hash:
     1679163164:
       localtime  1679163164
       hash:
   uiState:
   uiTable:
Attributes:
   icon       helper_doif
   room       ASC


Ich werde das jetzt mal beobachten, ob das so ist, wie wir uns das wünschen.

Viel Grüße
Stephan