ioBroker / ioBroker.node-red

Instantiate the server with node-red
Apache License 2.0
52 stars 27 forks source link

iobroker-list dynamic regex #273

Closed rewegit closed 2 years ago

rewegit commented 2 years ago

The iobroker-list can be configured via topic. This is very practical, e.g. if you put it in subflows. The output can be filtered with regex. This gives an enormous speed advantage compared to reading out the complete states with external filtering.

However, this is only possible statically, as it is not intended to pass the regex expression. Would it be possible to pass it, for example, in the payload or in a separate key?

GermanBluefox commented 2 years ago

Implemented in next version

mickym2 commented 2 years ago

In current git-hub version it is still not working.

Apollon77 commented 2 years ago

Can you show how you tried it?

Apollon77 commented 2 years ago

@mickym2 can you please recheck that too with latest GitHub version?

mickym2 commented 2 years ago

So I tested it and these are my results:

  1. Dynamically specifying a string in msg.regex is working and does the same thing in the editor gui, but
  2. this is not working with a regular Expression - in my opinion it just looks like the string is part of the ID (simple string contains)

image image

Regular expressions are not working well.

image

has no output

image

I have only .* is working as regEx

but other types of regular expression will fail - and there is no output at all.

Apollon77 commented 2 years ago

Ich hab mal eine Log Zeile eingefügt wenn er die Regex anwendet. dann sehen wir mal was er draus gemacht hat. Schau mal bitte

mickym2 commented 2 years ago

Aus

0_userdata\.\d.*

wird wohl

process list using regex /0_userdata\\.\d.*/

Apollon77 commented 2 years ago

lol ... ja ich sehe das Problem ... warte

Apollon77 commented 2 years ago

Retry please

mickym2 commented 2 years ago

wird eher schlimmer ;)

aus 0_userdata\.\d.* wird process list using regex /0_userdata\\.\\d.*/

Mit dem doppelten Backslash maskierst Du doch einen Backslash in regulären Ausdrücken?

Apollon77 commented 2 years ago

Heisst es tut nicht?? hhhmmm ... ok, dann versuch bitte mal eins (sollte an sich nicht gehen aber hey vltt haben wir falsch gedacht)

https://github.com/ioBroker/ioBroker.node-red/commit/7be4f9414018a634776d0f34a3e436b97ac4ce44

An den beiden Stellen mach das .replace(/\\/g, '\\\\') weg

Gehts dann?

mickym2 commented 2 years ago

In welcher Datei:

/opt/iobroker/node_modules/iobroker.node-red/nodes/ioBroker.js

(die ist aber vom Datum her alt)

Gesendet von Mail für Windows

Von: Ingo Fischer Gesendet: Donnerstag, 10. März 2022 18:33 An: ioBroker/ioBroker.node-red Cc: mickym2; Mention Betreff: Re: [ioBroker/ioBroker.node-red] iobroker-list dynamic regex (Issue#273)

Heisst es tut nicht?? hhhmmm ... ok, dann versuch bitte mal eins (sollte an sich nicht gehen aber hey vltt haben wir falsch gedacht) 7be4f94 An den beiden Stellen mach das .replace(/\/g, '\\') weg Gehts dann? — Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you were mentioned.Message ID: @.***>

mickym2 commented 2 years ago

OK - ich habe glaub die richtige Datei gefunden - aber nun habe ich wieder das wie vorher:

process list using regex /0_userdata\\.\d.*/

image

Apollon77 commented 2 years ago

aahh ... ich meinte mach mal das "replace" komplett weg.

also nur "...new RegExp(node.regex)"

mickym2 commented 2 years ago

Ja das funktioniert super. ;)

image aabf08caf2aa6b49: process list using regex /0_userdata\.\d\.testType\d$/

image

image

image

Diese Änderung ist approved-

Gibt aber noch ein anderes Problem mit der List Node - das ist mir erst die Tage aufgefallen - mach da ggf. neues Issue auf.

Apollon77 commented 2 years ago

Github updated!

And yes ... create issue ... then I check if we can get that in too

mickym2 commented 2 years ago

Nein fällt mir gerade nicht ein - falls mir was auffällt melde ich es - im Moment ist denke ich von der iobroker list node alles OK. ;)

Apollon77 commented 2 years ago

Released in 3.0.0