Calender > Calview > Notify > at

Begonnen von Paul Guijt, 27 Januar 2017, 22:34:56

Vorheriges Thema - Nächstes Thema

Paul Guijt

In meine Calender Agenda habe ich Termine wie
   1. Kennwort | set Lamp on | set Lamp off
   2. Kennwort | set Heating on
   3. Kennwort
Alle sind Termine mit ein Beginnzeit und Endezeit. Am Beginnzeit wird eine Lampe oder Heizung eingeschaltet. Oder wird FHEM den Auftrag mitgegeben "trigger Kennwort", also starte der Notify-Macro Kennwort. Am Endezeit wird nur die Lampe ausgeschaltet; in die andere Fälle wird nur am Beginnzeit etwas getan.

Es wirkt nur wenn das Kennwort ein Wort ist.

Erstens füge diese Code zu an myUtils.pm:
   

# Count or quote parts of a reading
# number 0: number of parts, number 1 - x: part 1 - x of the reading

sub ReadingsPart
{ my ($readingstext,$divider,$number) = @_ ;  my  @readingsparts = split /\Q$divider\E/,$readingstext ;
  if ($number eq "0") { return @readingsparts } else { return $readingsparts[$number - 1] ; } ; }


Dann in FHEM, mit eigene Name für Agenda*:
   
attr Agenda hideLaterThan 03:00
attr Agenda hideOlderThan 10

defmod Agendaitem CALVIEW Agenda
attr Agendaitem datestyle ISO8601
attr Agendaitem event-on-change-reading t_001_total,action_ID,action_b,action_e
attr Agendaitem maxreadings 1
attr Agendaitem modes next
attr Agendaitem userReadings action_type { ReadingsPart ( ReadingsVal("Agendaitem","t_001_summary",""),  "|"  , "0"  ) ;; },\
action_ID     { ReadingsPart ( ReadingsVal("Agendaitem","t_001_summary",""), " | " , "1"  ) ;; },\
action_b      { ReadingsPart ( ReadingsVal("Agendaitem","t_001_summary",""), " | " , "2"  ) ;; },\
action_e      { ReadingsPart ( ReadingsVal("Agendaitem","t_001_summary",""), " | " , "3"  ) ;; } ,\
t_001_total  { ReadingsVal("Agendaitem","t_001_bdatetimeiso","") . " " . ReadingsVal("Agendaitem","t_001_edatetimeiso","") . " " . ReadingsVal("Agendaitem","t_001_summary","") }

defmod AgendaitemActions notify
Agendaitem:t_001_total.* {
if (ReadingsVal ("Agendaitem","action_type","") eq "3")
{ fhem ("defmod B" . ReadingsVal("Agendaitem","action_ID","") . "at " . ReadingsVal("Agendaitem","t_001_bdatetimeiso","") . " " . ReadingsVal("Agendaitem","action_b","") . " ; defmod E" . ReadingsVal("Agendaitem","action_ID","") . "at " . ReadingsVal("Agendaitem","t_001_edatetimeiso","") . " " . ReadingsVal("Agendaitem","action_e","") );}
elsif (ReadingsVal ("Agendaitem","action_type","") eq "2")
{ fhem ("defmod A" . ReadingsVal("Agendaitem","action_ID","") . "at " . ReadingsVal("Agendaitem","t_001_bdatetimeiso","") . " " . ReadingsVal("Agendaitem","action_b","")  ); }
else { fhem ("defmod A" . ReadingsVal("Agendaitem","action_ID","") . "at " . ReadingsVal("Agendaitem","t_001_bdatetimeiso","") . " trigger " . ReadingsVal("Agendaitem","action_ID","")  ); }
}



RasPi 2B, CUL 433, Jens' FW, Berker, HomeMatic, KlikaanKlikuit, RFXtrx443, Squeezebox, Z-Wave, TradFri in die Niederlände