Hauptmenü

FHEM Modul erstellen

Begonnen von fhem86, 13 April 2013, 19:53:20

Vorheriges Thema - Nächstes Thema

fhem86

Hallo Zusammen,

ich möchte ein FHEM Modul erstellen.

ich habe die Datei "99_andnotify.pm" mit folgendem Inhalt erstellt (Basis war das notify Modul):

package main;

use strict;
use warnings;

#####################################
sub
andnotify_Initialize($)
{
  my ($hash) = @_;

  $hash->{DefFn} = "andnotify_Define";
  $hash->{NotifyFn} = "andnotify_Exec";
  $hash->{AttrFn}   = "andnotify_Attr";
  $hash->{AttrList} = "loglevel:0,1,2,3,4,5,6";
}


#####################################
sub
andnotify_Define($$)
{
  my ($hash, $def) = @_;
  my ($name, $type, $re, $command) = split("[ \t]+", $def, 4);

  if(!$command) {
    if($hash->{OLDDEF}) { # Called from modify, where command is optional
      (undef, $command) = split("[ \t]+", $hash->{OLDDEF}, 2);
      $hash->{DEF} = "$re $command";
    } else {
      return "Usage: define <name> andnotify <regexp> <command>";
    }
  }

  # Checking for misleading regexps
  eval { "Hallo" =~ m/^$re$/ };
  return "Bad regexp: $@" if($@);
  $hash->{REGEXP} = $re;
  $hash->{STATE} = "active";

  return undef;
}


FHEM wurde neugestartet und folgende Zeile in die Konfig geschrieben:

define blub andnotify myreg cmd


Nach dem speichern bekomme ich diesen Fehler:

Unknown module andnotify, choose one of .....


Muss ich das das Modul noch irgendwo anders eintragen?

Gruß & Danke

Dietmar63

versuch mal  ein "reload 99_andnotify".
sonst neu starten.
Gruß Dietmar
FB7390, CUL, 2 FHT, FS20
modules: 98_WOL.pm, 98_Heating_Control.pm,   98_WeekdayTimer.pm, 98_RandomTimer.pm, 59_Twilight.pm

fhem86

Hat sich erledigt

Ich habe das STV Modul als Basis genommen.

Jetzt funktioniert es.

Danke