[GELÖST] Warum klappt das nicht? Notify

Begonnen von Kaspi, 12 August 2021, 14:46:00

Vorheriges Thema - Nächstes Thema

Kaspi

Getz aber



ALARM_SENDER_3_BYTE:ALARM_INPUT:.* {

if (substr($EVTPART1,0,1)){
fhem("set ALARM_12V_OK on");;}
else{
fhem("set ALARM_12V_OK off");;}

if (substr($EVTPART1,1,1)){
fhem("set ALARM_GND_OK on");;}
else{
fhem("set ALARM_GND_OK off");;}

if (substr($EVTPART1,2,1)){
fhem("set ALARM_EIN_AUS on");;}
else{
fhem("set ALARM_EIN_AUS off");;}


...
...
...




Jamo

Yep, sieht fast gut aus! Aber wegen den doppelten ";;" :
In der Definition selber muss nur nur ein ; sein, und selbst das kannst Du weglassen.
Es muss also so aussehen:
...
if (substr($EVTPART1,0,1)){
fhem("set ALARM_12V_OK on");}
else{
fhem("set ALARM_12V_OK off");}


oder

if (substr($EVTPART1,2,1)){
fhem("set ALARM_EIN_AUS on")}
else{
fhem("set ALARM_EIN_AUS off")}


Ich frage weil Du das notify nicht in in der RAW definition gezeigt hast, dann hätten wir noch einen \ als Zeilentrenner gesehen.
Aber zwei ;; in der definition des notify sind falsch.
Bullseye auf iNUC, Homematic + HMIP(UART/HMUSB), Debmatic, HUEBridge, Zigbee/Conbee III, FB7690, Alexa (fhem-lazy), Livetracking, LaCrosse JeeLink, LoRaWan / TTN / Chirpstack, Sonos, ESPresence

Damian

Wenn man etwas tiefer in Perl steckt, dann kann man es auch etwas kürzer schreiben:

ALARM_SENDER_3_BYTE:ALARM_INPUT:.* {
my @a=("off","on");;
fhem ("set ALARM_12V_OK ".$a[$EVTPART1 & "1"]);;
fhem ("set ALARM_GND_OK ".$a[$EVTPART1 & "01"]);;
fhem ("set ALARM_EIN_AUS ".$a[$EVTPART1 & "001"]);;
....
}
Programmierte FHEM-Module: DOIF-FHEM, DOIF-Perl, DOIF-uiTable, THRESHOLD, FHEM-Befehl: IF