ocervinka / plccoms-mqtt-bridge

Bi-directional communication bridge between Teco's PLCComS and MQTT broker
5 stars 0 forks source link

An issue with array variables in configuration #15

Closed pes001 closed 1 year ago

pes001 commented 1 year ago

Hi @ocervinka, I was having problems reading array variables via PLCComs from my Foxtrot - for example CIDLA[3].PORUCHA. These variables were listed but had no content. I found out that the problem is in the configuration.yaml: if there are square brackets in the variable name, these variables are not mapped by the bridge. Example:

The workaround I have found is to use the * syntax, for example:

Someone might find this helpful. Of course, there is room for future improvement :) Regards, Petr

ocervinka commented 1 year ago

[ je vyhrazeny znak pro regexp, tak v tvem pripade pred nej pridej escape znak \

MISTNOST_M\[3].TIMERENA

Stejne tak znak .(cokoli), tzn. napr. promenne MISTNOST_M\[3]_TIMERENA nebo MISTNOST_M\[3]XTIMERENA a dalsi budou vsechny exportovane do topiku MISTNOST_M[3].TIMERENA

Takze pro striktni match je potreba pouzit escape i pro znak .

MISTNOST_M\[3]\.TIMERENA

Btw, jestli mas hodne promennych, ktere se lisi jen indexem a chces kazdou do odpovidajiciho topiku, muzes pouzit jeden zapis s regexp group a konfigurace pro plccoms-mqtt-bridge bude prehlednejsi.

var: "MISTNOST_M\[([0-9]+)]\.TIMERENA"
state topic: "MISTNOST_M[{1}].TIMERENA"
pes001 commented 1 year ago

OK, diky za vysvetleni a nasmerovani. Pouzivam tu syntaxi s teckou a zda se, ze to funguje bez problemu. Uzaviram issue 👍