FHEM > English Corner

Where do I put sub routines?

(1/2) > >>

Fonz:
Hi,

Thanks again for this great application.

Im learning a lot but would like to include a sub routine into Fhem.

I have seen some code that I would like to include, but I dont know where to put it?

Can I just put the following in the config file, or do I need to put it into one of the 99 files?

By the way, what are the 99 files for?

Here is the code, if someone could tell me where to paste it I would be very grateful.


--- Zitat ---16. Setting auto-mode from manual for the FHT won't change the desired temperature!

Thanks to Waldemar Porsche the following notify will take care of that:
define ExtendedAutoMode notify .*mode.*auto {\
    $r = $defs{@}{READINGS};;\
    return if (!defined($r));;\
    my $olddesired = $r->{"desired-temp"}{VAL};;\
    return if (!defined($olddesired));;\
    my @@day = ("sun", "mon", "tue", "wed", "thu", "fri", "sat");;\
    my $now = sprintf("%%02d:%%02d", $hour, $min);;\
    my $wd = $day[$wday];;\
    my $desired;;\
    if (defined($r->{"warnings"}{VAL}) && $r->{"warnings"}{VAL} eq "Window open") {\
      $desired = $r->{"windowopen-temp"}{VAL};;\
    } elsif (defined($r->{"$wd-from1"}{VAL}) && $r->{"$wd-from1"}{VAL} le $now && defined($r->{"$wd-to1"}{VAL}) && $r->{"$wd-to1"}{VAL} ge $now) {\
      $desired = $r->{"day-temp"}{VAL};;\
    } elsif (defined($r->{"$wd-from2"}{VAL}) && $r->{"$wd-from2"}{VAL} le $now && defined($r->{"$wd-to2"}{VAL}) && $r->{"$wd-to2"}{VAL} ge $now) {\
      $desired = $r->{"day-temp"}{VAL};;\
    } else {\
      $desired = $r->{"night-temp"}{VAL};;\
    }\
    fhem ("set @ desired-temp $desired") if (defined($desired) && $desired ne $olddesired);;\
  }
  attr ExtendedAutoMode comment Setzt fuer den Auto mode die desired-temp in Abhaengigkeit von Temperaturprofil und Fensterkontakt
--- Ende Zitat ---


Fon

jhohn:
create a file 99_myUtils.pm in fhem/FHEM and put it in there. Then restart fhem. Files beginning with 99_ will be automatically included on system start.

jhohn:
missing that edit mode ...


the notify needs to be in fhem.cfg

Fonz:
Thanks for the reply.

So the line


--- Zitat ---define ExtendedAutoMode notify .*mode.*auto {\
--- Ende Zitat ---


should be in the cfg file and then,


--- Zitat ---$r = $defs{@}{READINGS};;\
    return if (!defined($r));;\
    my $olddesired = $r->{"desired-temp"}{VAL};;\
    return if (!defined($olddesired));;\
    my @@day = ("sun", "mon", "tue", "wed", "thu", "fri", "sat");;\
    my $now = sprintf("%%02d:%%02d", $hour, $min);;\
    my $wd = $day[$wday];;\
    my $desired;;\
    if (defined($r->{"warnings"}{VAL}) && $r->{"warnings"}{VAL} eq "Window open") {\
      $desired = $r->{"windowopen-temp"}{VAL};;\
    } elsif (defined($r->{"$wd-from1"}{VAL}) && $r->{"$wd-from1"}{VAL} le $now && defined($r->{"$wd-to1"}{VAL}) && $r->{"$wd-to1"}{VAL} ge $now) {\
      $desired = $r->{"day-temp"}{VAL};;\
    } elsif (defined($r->{"$wd-from2"}{VAL}) && $r->{"$wd-from2"}{VAL} le $now && defined($r->{"$wd-to2"}{VAL}) && $r->{"$wd-to2"}{VAL} ge $now) {\
      $desired = $r->{"day-temp"}{VAL};;\
    } else {\
      $desired = $r->{"night-temp"}{VAL};;\
    }\
    fhem ("set @ desired-temp $desired") if (defined($desired) && $desired ne $olddesired);;\
  }
  attr ExtendedAutoMode comment Setzt fuer den Auto mode die desired-temp in Abhaengigkeit von Temperaturprofil und Fensterkontakt
--- Ende Zitat ---


Should be in the newly created 99_myUtils.pm file?

It or should only the


--- Zitat ---define ExtendedAutoMode notify .*mode.*auto
--- Ende Zitat ---


Be in the CFG file? with the rest in the 99_myUtils.pm file?

Thanks again,

Fonz

jhohn:
This whole thing lookes just like one notify and needs to be in fhem.cfg. The last line, beginning with attr, is a comment telling "this will set the desired-temp for auto-mode respecting temp-profiles and window contacts"

Navigation

[0] Themen-Index

[#] Nächste Seite

Zur normalen Ansicht wechseln