FHEM Forum

FHEM => Anfängerfragen => Thema gestartet von: Meck am 25 Juni 2019, 14:37:42

Titel: [Gelöst]Verständnis Problem Erstellen von Notfications aus einer Subroutine
Beitrag von: Meck am 25 Juni 2019, 14:37:42
Verständnis Problem Erstellen von Notfications aus einer Subroutine
Hallo ich versuche gerade mein Verständnis zu verbessern leider komme ich aktuell nicht weiter.

Ich habe mir eine Sub Routine in 99_myUtils.pm erstellt die jeweils ein Notify erstellen soll.

Nutze ich die folgende Zeile in der Kommandozeile in FHEM, erstellt mir FHEM wie gewohnt ein notfy Namens b. Es wird a Überwacht die Subroutine detection mit der Übergabe a ausgeführt. So ist aktuell auch meine Erwartungshaltung, wenn ich dies aus einer Subroutine machen möchte
define b notify a {detection("a")}
Versuche ich das Ganze in einer Subroutine erstellt er mir diese nicht.
fhem ("define $b notify $a {detection($a)}");
Folgende Zeile erstellt mir eine Subroutine. Leider hat diese aber kein Aufruf einer weiteren Routine mit Übergabewert
fhem ("define $b notify $a set $c on)}");

Also denke ich das es an{detection($a)} liegt.

Mit den beiden Zeilen wirft FHEM mir ein Syntaxfehler aus.
{detection("$a")}
{detection(""$a"")}

Es ist sehr nett wenn mir kurz einer/eine auf die Beine helfen kann.

Gruß

Meck

Titel: Antw:Verständnis Problem Erstellen von Notfications aus einer Subroutine
Beitrag von: Otto123 am 25 Juni 2019, 14:46:35
Hi Meck,

fhem ("define $b notify $a {detection($a)}"); Was erscheint dabei im Log?
Was erwartest Du für ein notify?
Ganzer Satz (geraten):
{my $a="willi;my $b="lustig";fhem ("define $b notify $a {detection($a)}")}
Du willst
define lustig notify willi {detection(willi)}
oder
define lustig notify willi {detection($a)}

Bei der zweiten Variante müsstest Du die Auflösung von $a verhindern -> \$a

Edit: ok nochmal gelesen, Du willst die erste Variante. :)
Edit2: Ja ok verstanden Dan hat Recht und die Lösung :)

Gruß Otto
Titel: Antw:Verständnis Problem Erstellen von Notfications aus einer Subroutine
Beitrag von: DeeSPe am 25 Juni 2019, 14:48:50
Ich glaube er sucht das Escapen:
fhem ("define $b notify $a {detection(\"$a\")}");
oder ohne Escapen:
fhem ("define $b notify $a {detection('$a')}");

Gruß
Dan
Titel: Antw:Verständnis Problem Erstellen von Notfications aus einer Subroutine
Beitrag von: Meck am 25 Juni 2019, 15:25:55
Vielen Dank für eure Antwort werde es heute Abend mal anschauen.

Ansich suche ich so was was ich in 99_myUtils.pm in eine subroutine rein schreibe.

my $a="willi;
my $b="lustig";
fhem ("define $b notify $a {detection($a)}")};
$a = "max";
$b = "traurig"
fhem ("define $b notify $a {detection($a)}")};


und sich wie das händische Erstellen verhält.

fhem: define lustig notify willi {detection(willi)}
fhem: define traurug notify max{detection(max)}


Gruß
Meck
Titel: Antw:Verständnis Problem Erstellen von Notfications aus einer Subroutine
Beitrag von: Meck am 25 Juni 2019, 20:58:48
Hallo,
Danke für eure Unterstützung. Escapen war das Schlüsselwort mit dem meine Lieblingssuchmaschine mir das alles erklären konnte.


Das war die Lösung zu meinem Ziel.
  fhem ("define $b notify $a {detection('$a')}");

Gruß

Meck