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
versuch mal ein "reload 99_andnotify".
sonst neu starten.
Hat sich erledigt
Ich habe das STV Modul als Basis genommen.
Jetzt funktioniert es.
Danke