FHEM Forum

FHEM => Anfängerfragen => Thema gestartet von: HM Krause am 08 März 2020, 18:06:56

Titel: PERL WARNINGs beim Shutdown [GELÖST]
Beitrag von: HM Krause am 08 März 2020, 18:06:56
Ich hab mir was gebaut, mit Infrarot TSOP4838 (am nodeMCU GPiO14 mit Tasmota) über MQTT (Mosquitto) in FHEM die Sonoff S20 WLAN Steckdosen schalten.
Funktioniert soweit auch alles. Die notify-Einträge habe ich -wie im Forum empfohlen- nicht in die fhem.cfg hinein editiert, sondern mit dem Event-Monitor erzeugt.

Hier mal ein Auszug:

define TSOP4838_notify_1 notify TSOP4838:Sensor:.{"IrReceived":{"Protocol":"SONY","Bits":20,"Data":"A0B92"}} set sonoffswitchS201 ON
setuuid TSOP4838_notify_1 5e594c96-f33f-3a18-23c8-8279919d70800bee
define TSOP4838_notify_2 notify TSOP4838:Sensor:.{"IrReceived":{"Protocol":"SONY","Bits":20,"Data":"B92"}} set sonoffswitchS201 OFF
setuuid TSOP4838_notify_2 5e594dbe-f33f-3a18-4e87-2f171d97882a374c
define TSOP4838_notify_3 notify TSOP4838:Sensor:.{"IrReceived":{"Protocol":"SONY","Bits":20,"Data":"60B92"}} set sonoffswitchS202 ON
setuuid TSOP4838_notify_3 5e594e51-f33f-3a18-5de9-7abab3054166847c
define TSOP4838_notify_4 notify TSOP4838:Sensor:.{"IrReceived":{"Protocol":"SONY","Bits":20,"Data":"80B92"}} set sonoffswitchS202 OFF
setuuid TSOP4838_notify_4 5e594e80-f33f-3a18-f109-9e36076db062b322


Die dazu passenden Perl-Warnings kommen beim runterfahren (shutdown/restart) vom FHEM-Server und sehen dann so aus:

2020.03.08 17:44:53 0: Server shutdown
2020.03.08 17:44:53 1: Shutdown executed
2020.03.08 17:44:53 1: Including fhem.cfg
2020.03.08 17:44:54 3: WEB: port 8083 opened
2020.03.08 17:44:54 2: eventTypes: loaded 551 events from ./log/eventTypes.txt
2020.03.08 17:44:54 1: PERL WARNING: Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/^TSOP4838:Sensor:.{"IrReceived":{ <-- HERE "Protocol":"SONY","Bits":20,"Data":"A0B92"}}$/ at ./FHEM/91_notify.pm line 56.
2020.03.08 17:44:54 1: PERL WARNING: Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/^TSOP4838:Sensor:.{"IrReceived":{ <-- HERE "Protocol":"SONY","Bits":20,"Data":"A0B92"}}$/ at ./FHEM/91_notify.pm line 69.
2020.03.08 17:44:54 1: PERL WARNING: Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/^TSOP4838:Sensor:.{"IrReceived":{ <-- HERE "Protocol":"SONY","Bits":20,"Data":"B92"}}$/ at ./FHEM/91_notify.pm line 56.
2020.03.08 17:44:54 1: PERL WARNING: Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/^TSOP4838:Sensor:.{"IrReceived":{ <-- HERE "Protocol":"SONY","Bits":20,"Data":"B92"}}$/ at ./FHEM/91_notify.pm line 69.


Ich ab mal in FHEM probiert, an den { was zu ändern, war aber erfolglos. Die Infrarot-Fernbedienung hat danach einfach mit der passenden Taste dann nicht mehr funktioniert.
Was ist da falsch? Die notifies hat FHEM erzeugt, ich kenne mich mit der PERL-Syntax ohnehin nicht aus.
Ich fand noch:
Use of unescaped "{" immediately after a "(" in regular expression patterns

Using unescaped left braces is officially deprecated everywhere, but it is not enforced in contexts where their use does not interfere with expected extensions to the language. A deprecation is added in this release when the brace appears immediately after an opening parenthesis. Before this, even if the brace was part of a legal quantifier, it was not interpreted as such, but as the literal characters, unlike other quantifiers that follow a "(" which are considered errors. Now, their use will raise a deprecation message, unless turned off.

Aber ich kann das nicht richtig anwenden.
Titel: Antw:PERL WARNINGs beim Shutdown
Beitrag von: Otto123 am 08 März 2020, 18:39:11
Hi,

klingt alles wie von Hinten durch die Brust ...

Die notify würde ich so in der Art abändern/kürzen:
define TSOP4838_notify_1 notify TSOP4838:Sensor:.*A0B92.* set sonoffswitchS201 ON

Er mag die { Klammern dort nicht, könnte man escapen - aber wozu?

Warum machst Du das ganz nicht direkt mit MQTT2 Geräten - da geht das direkt im Gerät ohne Notify Ich habe nicht richtig gelesen :(

Gruß Otto
Titel: Antw:PERL WARNINGs beim Shutdown [gelöst]
Beitrag von: HM Krause am 08 März 2020, 19:11:27
jetzt hab ich es selbst auch gefunden, es muß heißen "IrReceived":\
You can always escape the special characters, in this case the at-mark @ by using the so-called escape character which is the back-slash \ character.
Ich hab hier MQTT und mach es nicht mit MQTT2 Geräten.