Extract two values from mqtt message(json type) and create a new mqtt with these two

hi Colin, thanks for explain.
i think that i did in post above, where Andrei expain to me.

here the output:
if you need something else, please ask me.
thanks again for support and suggestion!

i set as this:

it's the output taken from here:


simply copi-paste from that windows.
it's correct?
i do not find others way to export the debug.

here the copy-paste:

3/3/2020, 10:47:51[node: 9badb8d6.0b475](http://192.168.0.105:1880/#)

domoticz/out : msg.payload : Object

{ Battery: 255, RSSI: 12, description: "", dtype: "Temp + Humidity", hwid: "6" ā€¦ }

3/3/2020, 10:47:52[node: 9badb8d6.0b475](http://192.168.0.105:1880/#)domoticz/out : msg.payload : Object

{ Battery: 255, RSSI: 12, description: "topic=tasmota_blindā†µblind=1", dtype: "Light/Switch", hwid: "6" ā€¦ }

3/3/2020, 10:47:54[node: 9badb8d6.0b475](http://192.168.0.105:1880/#)domoticz/out : msg.payload : Object

{ Battery: 255, RSSI: 12, description: "topic=tasmota_blindā†µblind=2", dtype: "Light/Switch", hwid: "6" ā€¦ }

3/3/2020, 10:47:55[node: 9badb8d6.0b475](http://192.168.0.105:1880/#)domoticz/out : msg.payload : Object

{ Battery: 255, RSSI: 12, description: "topic=tasmota_blindā†µblind=3", dtype: "Light/Switch", hwid: "6" ā€¦ }

3/3/2020, 10:47:56[node: 9badb8d6.0b475](http://192.168.0.105:1880/#)domoticz/out : msg.payload : Object

{ Battery: 255, RSSI: 12, description: "", dtype: "Temp + Humidity", hwid: "6" ā€¦ }

3/3/2020, 10:47:56[node: 9badb8d6.0b475](http://192.168.0.105:1880/#)domoticz/out : msg.payload : Object

{ Battery: 255, RSSI: 7, description: "", dtype: "Temp", hwid: "6" ā€¦ }

3/3/2020, 10:47:57[node: 9badb8d6.0b475](http://192.168.0.105:1880/#)domoticz/out : msg.payload : Object

{ Battery: 255, RSSI: 9, description: "", dtype: "Temp + Humidity", hwid: "6" ā€¦ }

3/3/2020, 10:47:58[node: 9badb8d6.0b475](http://192.168.0.105:1880/#)domoticz/out : msg.payload : Object

{ Battery: 255, RSSI: 7, description: "", dtype: "Temp", hwid: "6" ā€¦ }

3/3/2020, 10:47:58[node: 9badb8d6.0b475](http://192.168.0.105:1880/#)domoticz/out : msg.payload : Object

{ Battery: 255, RSSI: 12, description: "", dtype: "General", hwid: "6" ā€¦ }

3/3/2020, 10:47:59[node: 9badb8d6.0b475](http://192.168.0.105:1880/#)domoticz/out : msg.payload : Object

{ Battery: 255, EnergyMeterMode: "0", RSSI: 12, description: "", dtype: "General" ā€¦ }

3/3/2020, 10:47:59[node: 9badb8d6.0b475](http://192.168.0.105:1880/#)domoticz/out : msg.payload : Object

{ Battery: 255, RSSI: 12, description: "", dtype: "General", hwid: "6" ā€¦ }

but if for example, inside debug window expand the items clicking on the arrows and i copy-paste (same messages of code above, but just selected the first two), i obtain this:

domoticz/out : msg.payload : Object

object

Battery: 255

RSSI: 12

description: ""

dtype: "Temp + Humidity"

hwid: "6"

id: "82014"

idx: 14

name: "Corridoio"

nvalue: 0

stype: "THGN122/123/132, THGR122/228/238/268"

svalue1: "21.10"

svalue2: "36.0"

svalue3: "0"

unit: 1

3/3/2020, 10:47:52[node: 9badb8d6.0b475](http://192.168.0.105:1880/#)domoticz/out : msg.payload : Object

object

Battery: 255

RSSI: 12

description: "topic=tasmota_blindā†µblind=1"

dtype: "Light/Switch"

hwid: "6"

id: "000140F9"

idx: 169

name: "tap_tasmota_1"

nvalue: 2

stype: "Switch"

svalue1: "29"

switchType: "Blinds Percentage Inverted"

unit: 1

If you look at your very first post you will see it doens't look like that but is shown as a string. I think that was probably the debug from after the JSON node, which is converting it back from a javascript object to JSON string.
I haven't followed @Andrei's solution fully so I am not sure whether he has been working with the string or not.
If I were trying to solve this I would start by removing the JSON node so you have everything accessible as javascript objects and go from there. But as I said I have not been following carefully so perhaps that is already what you are doing.

[quote="Colin, post:22, topic:22512, full:true"]
If you look at your very first post you will see it doens't look like that but is shown as a string. I think that was probably the debug from after the JSON node, which is converting it back from a javascript object to JSON string.[/quote]

i think you are right, this is my firt flow:
immagine

and this is the output from firts mqtt node:

3/3/2020, 14:19:53[node: 9badb8d6.0b475](http://192.168.0.105:1880/#)

domoticz/out : msg.payload : Object

object

Battery: 255

RSSI: 12

description: ""

dtype: "Light/Switch"

hwid: "6"

id: "000140C7"

idx: 119

name: "rele_caldaia_ACS"

nvalue: 0

stype: "Switch"

svalue1: "0"

switchType: "On/Off"

unit: 1

and this the debug of second node: json


3/3/2020, 14:19:43node: 9e68d643.070a1
domoticz/out : msg.payload : string[240]
string[240]

{
    "Battery": 255,
    "RSSI": 12,
    "description": "",
    "dtype": "General",
    "hwid": "6",
    "id": "00082013",
    "idx": 13,
    "name": "Volt",
    "nvalue": 0,
    "stype": "Voltage",
    "svalue1": "227.60",
    "unit": 1
}

what type is better to work for you?

and second question: on my previus post where i reply to you, i reported the outcome from debug, first is not expanding the output, and copy-paste here
second outcome from debug is copy-paste expanding the box inside debug.
there are differences on that only for "visualization" here?
for example if i take debug output of json i see:
not compress:

{
    "Battery": 255,
    "RSSI": 12,
    "description": "",
    "dtype": "General",
    "hwid": "6",
    "id": "00082013",
    "idx": 13,
    "name": "Volt",
    "nvalue": 0,
    "stype": "Voltage",
    "svalue1": "227.60",
    "unit": 1
}

copy-paste compressed:
"{ā†µ "Battery": 255,ā†µ "RSSI": 12,ā†µ "description": "",ā†µ "dtype": "P1 Smart Meter",ā†µ "hwid": "6",ā†µ "id": "82101",ā†µ "idx": 101,ā†µ "name": "Acqua",ā†µ "nvalue": 0,ā†µ "stype": "Gas",ā†µ "svalue1": "730746.0",ā†µ "unit": 1ā†µ}"

there are the ā†µ symbles here.

you mean with setting this type of json inside mqtt input node: a parsed JSON object ?
immagine
thanks

The difference between the two is that the output from the mqtt with output set to parsed json is an object (note it says

domoticz/out : msg.payload : Object```

the message from mqtt has been parsed from JSON into a javascript object, whereas after the JSON node it is a string

domoticz/out : msg.payload : string[240]

becase the JSON node has converted it back to a JSON string (JSON is always a string). The difference is that with it as an object you can refer to, for example, the Battery value just by using msg.payload.Battery whereas with it as a string you need to start searching the string for the relevant text. Have a look at node red docs page Working with Messages which should help to understand it.

ok, nice to see that we will be able to work with objects as our input data. The only place where we can get line feeds characters is on the description field, which is not a big issue. I will then proceed with finishing the flow.

Edit: I am staring at the flow without knowing what else to do :thinking: I think it should work fine when you remove the inject nodes and connect the MQTT node to the change node. May you give it a try ?

ehmm nothing else :slight_smile:
substitution of injection block with mqtt should generate the correct output.


i connect a mqtt inuput and i wrote as topic domoticz/out
i connect at the end of the flow an mqtt out and i do not write nothing inside topic.
now i see a very strange behaviour....
i see many relays triggering.
relays that's are related to lights and so no....relay that are not for blinds...!!
maybe because mqtt domoticz/out will pass many json not the only one connecte to the blind that we have to transform, and using JSONata it will modify and use also messages that are not for blinds, mqtt output will sendout messages that's are not correct for other devices?

other two questions.
As Colin wrote, due to the fact that json is now a string but an object, we can not "taking" the value directing from the json?
as Coling wrote for example, the Battery value just by using msg.payload.Battery ??
and is it not better using a different formatation of data stored in description field?
thanks.

ps. when you have time, can you please explain this from current flow:

the template, as you wrote, will complete all the parts transformed by jsonata
{{{newname2}}} {{payload.svalue1}}

newname2 is made by: part3 (that is: cmnd/)
and newname2 that is made by: shutterposition
so it become
cmnd/shutterposition
then there is: {{payload.svalue1}}
that i guess is able to take value from json injection
two sub questions:
1a) just to learn.
if i use for example: {{payload.stype}} instead of {{payload.svalue1}}
i will find: Switch as result ?
because inside injection json i have as "stype" : "Switch"
correct?

2a) thanks to template block:
{{{newname2}}} {{payload.svalue1}}
at command we have:
cmnd/shutterposition
that's newname2
but the righ comand is: cmnd/ topic_bla_bla_bla /shutterposition 8 43 (for example)
where you take the number 8 of the example above? i do not understand
and where you take the topic_bla_bla_bla ??
and how you build the construction of commands output?
thanks

So letĀ“s fix it. The best thing to do is to create a branch in the flow that separates topics. We will process only messages that have the string tasmota_blind in the middle. What do you think ?

This will be the configuration of the switch node.

a-02

and this is the testing flow:

[{"id":"23dc9ff4.66a6a","type":"inject","z":"b3412710.dacd38","name":"topic=tasmota_blind\\nblind=1","topic":"","payload":"{\"Battery\":255,\"RSSI\":12,\"description\":\"topic=tasmota_blind\\nblind=1\",\"dtype\":\"Light/Switch\",\"hwid\":\"6\",\"id\":\"000140F9\",\"idx\":169,\"name\":\"tap_tasmota_1\",\"nvalue\":2,\"stype\":\"Switch\",\"svalue1\":\"59\",\"switchType\":\"Blinds Percentage Inverted\",\"unit\":1}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":280,"y":700,"wires":[["21c32c3d.7c7ce4"]]},{"id":"8cde46f9.379ee8","type":"inject","z":"b3412710.dacd38","name":"topic=tasmota_blind2\\nblind=3","topic":"","payload":"{\"Battery\":255,\"RSSI\":12,\"description\":\"topic=tasmota_blind2\\nblind=3\",\"dtype\":\"Light/Switch\",\"hwid\":\"6\",\"id\":\"000140FB\",\"idx\":171,\"name\":\"tamp_tasmota_3\",\"nvalue\":2,\"stype\":\"Switch\",\"svalue1\":\"85\",\"switchType\":\"Blinds Percentage Inverted\",\"unit\":1}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":280,"y":760,"wires":[["21c32c3d.7c7ce4"]]},{"id":"2e8d1303.f0ae3c","type":"change","z":"b3412710.dacd38","name":"JSONata","rules":[{"t":"set","p":"part1","pt":"msg","to":"payload.description","tot":"jsonata"},{"t":"set","p":"part2","pt":"msg","to":"$replace(part1,\"\\n\", \"/\")","tot":"jsonata"},{"t":"set","p":"part3","pt":"msg","to":"$replace(part2,\"topic=\", \"cmnd/\")","tot":"jsonata"},{"t":"set","p":"newname2","pt":"msg","to":"$replace(part3,\"blind=\", \"shutterposition\")","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":660,"y":840,"wires":[["22e114ab.d7bdec"]]},{"id":"591173f7.2bdcdc","type":"debug","z":"b3412710.dacd38","name":"Replace by a MQTT out node","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1040,"y":840,"wires":[]},{"id":"22e114ab.d7bdec","type":"template","z":"b3412710.dacd38","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{{{newname2}}} {{payload.svalue1}}","output":"str","x":820,"y":840,"wires":[["591173f7.2bdcdc"]]},{"id":"4c003b81.ec8584","type":"inject","z":"b3412710.dacd38","name":"tap_tasmota_1","topic":"","payload":"{\"Battery\":255,\"RSSI\":12,\"description\":\"\",\"dtype\":\"Light/Switch\",\"id\":\"000140F9\",\"idx\":169,\"name\":\"tap_tasmota_1\",\"nvalue\":2,\"stype\":\"Switch\",\"svalue1\":\"38\",\"switchType\":\"Blinds Percentage Inverted\",\"unit\":1}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":320,"y":820,"wires":[["21c32c3d.7c7ce4"]]},{"id":"dabf9471.ab2b48","type":"inject","z":"b3412710.dacd38","name":"tap_tasmota_2","topic":"","payload":"{\"Battery\":255,\"RSSI\":12,\"description\":\"\",\"dtype\":\"Light/Switch\",\"id\":\"000140F9\",\"idx\":169,\"name\":\"tap_tasmota_2\",\"nvalue\":2,\"stype\":\"Switch\",\"svalue1\":\"38\",\"switchType\":\"Blinds Percentage Inverted\",\"unit\":1}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":320,"y":880,"wires":[["21c32c3d.7c7ce4"]]},{"id":"68f907fd.24cdb8","type":"inject","z":"b3412710.dacd38","name":"fake_tasmota_2","topic":"","payload":"{\"Battery\":255,\"RSSI\":12,\"description\":\"\",\"dtype\":\"Light/Switch\",\"id\":\"000140F9\",\"idx\":169,\"name\":\"fake_tasmota_2\",\"nvalue\":2,\"stype\":\"Switch\",\"svalue1\":\"38\",\"switchType\":\"Blinds Percentage Inverted\",\"unit\":1}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":320,"y":940,"wires":[["21c32c3d.7c7ce4"]]},{"id":"21c32c3d.7c7ce4","type":"switch","z":"b3412710.dacd38","name":"","property":"payload.description","propertyType":"msg","rules":[{"t":"cont","v":"tasmota_blind","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":510,"y":840,"wires":[["2e8d1303.f0ae3c"],["d9ba8e9f.8c6ac"]]},{"id":"d9ba8e9f.8c6ac","type":"debug","z":"b3412710.dacd38","name":"debug2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":690,"y":920,"wires":[]}]

I comment the other questions after we sort out this issue.

Hi Andrei, i tested your flow like this:

[{"id":"fe7efaec.233288","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"fccc17e4.f88d6","type":"inject","z":"fe7efaec.233288","name":"topic=tasmota_blind\\nblind=1","topic":"","payload":"{\"Battery\":255,\"RSSI\":12,\"description\":\"topic=tasmota_blind_test\\nblind=1\",\"dtype\":\"Light/Switch\",\"hwid\":\"6\",\"id\":\"000140F9\",\"idx\":169,\"name\":\"tap_tasmota_1\",\"nvalue\":2,\"stype\":\"Switch\",\"svalue1\":\"59\",\"switchType\":\"Blinds Percentage Inverted\",\"unit\":1}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":160,"y":160,"wires":[["71981d7e.1b8cd4"]]},{"id":"5a312885.8a44d","type":"inject","z":"fe7efaec.233288","name":"topic=tasmota_blind2\\nblind=3","topic":"","payload":"{\"Battery\":255,\"RSSI\":12,\"description\":\"topic=tasmota_blind2\\nblind=3\",\"dtype\":\"Light/Switch\",\"hwid\":\"6\",\"id\":\"000140FB\",\"idx\":171,\"name\":\"tamp_tasmota_3\",\"nvalue\":2,\"stype\":\"Switch\",\"svalue1\":\"85\",\"switchType\":\"Blinds Percentage Inverted\",\"unit\":1}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":160,"y":220,"wires":[["71981d7e.1b8cd4"]]},{"id":"6db9030f.c25c7c","type":"change","z":"fe7efaec.233288","name":"JSONata","rules":[{"t":"set","p":"part1","pt":"msg","to":"payload.description","tot":"jsonata"},{"t":"set","p":"part2","pt":"msg","to":"$replace(part1,\"\\n\", \"/\")","tot":"jsonata"},{"t":"set","p":"part3","pt":"msg","to":"$replace(part2,\"topic=\", \"cmnd/\")","tot":"jsonata"},{"t":"set","p":"newname2","pt":"msg","to":"$replace(part3,\"blind=\", \"shutterposition\")","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":540,"y":300,"wires":[["6d9e6d3c.c24934"]]},{"id":"55bd64f5.91deb4","type":"debug","z":"fe7efaec.233288","name":"Replace by a MQTT out node","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":920,"y":300,"wires":[]},{"id":"6d9e6d3c.c24934","type":"template","z":"fe7efaec.233288","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{{{newname2}}} {{payload.svalue1}}","output":"str","x":700,"y":300,"wires":[["55bd64f5.91deb4","fea66967.f7f5a8"]]},{"id":"9f232820.eac82","type":"inject","z":"fe7efaec.233288","name":"tap_tasmota_1","topic":"","payload":"{\"Battery\":255,\"RSSI\":12,\"description\":\"\",\"dtype\":\"Light/Switch\",\"id\":\"000140F9\",\"idx\":169,\"name\":\"tap_tasmota_1\",\"nvalue\":2,\"stype\":\"Switch\",\"svalue1\":\"38\",\"switchType\":\"Blinds Percentage Inverted\",\"unit\":1}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":200,"y":280,"wires":[["71981d7e.1b8cd4"]]},{"id":"d5085fff.08a848","type":"inject","z":"fe7efaec.233288","name":"tap_tasmota_2","topic":"","payload":"{\"Battery\":255,\"RSSI\":12,\"description\":\"\",\"dtype\":\"Light/Switch\",\"id\":\"000140F9\",\"idx\":169,\"name\":\"tap_tasmota_2\",\"nvalue\":2,\"stype\":\"Switch\",\"svalue1\":\"38\",\"switchType\":\"Blinds Percentage Inverted\",\"unit\":1}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":200,"y":340,"wires":[["71981d7e.1b8cd4"]]},{"id":"48853280.ec1d54","type":"inject","z":"fe7efaec.233288","name":"fake_tasmota_2","topic":"","payload":"{\"Battery\":255,\"RSSI\":12,\"description\":\"\",\"dtype\":\"Light/Switch\",\"id\":\"000140F9\",\"idx\":169,\"name\":\"fake_tasmota_2\",\"nvalue\":2,\"stype\":\"Switch\",\"svalue1\":\"38\",\"switchType\":\"Blinds Percentage Inverted\",\"unit\":1}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":200,"y":400,"wires":[["71981d7e.1b8cd4"]]},{"id":"71981d7e.1b8cd4","type":"switch","z":"fe7efaec.233288","name":"","property":"payload.description","propertyType":"msg","rules":[{"t":"cont","v":"tasmota_blind","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":390,"y":300,"wires":[["6db9030f.c25c7c"],["676fe8f4.17aea8"]]},{"id":"676fe8f4.17aea8","type":"debug","z":"fe7efaec.233288","name":"debug2","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":570,"y":380,"wires":[]},{"id":"d56c8c53.d3cfd","type":"inject","z":"fe7efaec.233288","name":"topic=tasmota_blind11\\nblind=46","topic":"","payload":"{\"Battery\":255,\"RSSI\":12,\"description\":\"nodered=test\\ntopic=tasmota_blind11\\nblind=46\",\"dtype\":\"Light/Switch\",\"hwid\":\"6\",\"id\":\"000140FB\",\"idx\":171,\"name\":\"tamp_tasmota_3\",\"nvalue\":2,\"stype\":\"Switch\",\"svalue1\":\"85\",\"switchType\":\"Blinds Percentage Inverted\",\"unit\":1}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":170,"y":480,"wires":[["71981d7e.1b8cd4"]]},{"id":"89c946d1.82a48","type":"mqtt in","z":"fe7efaec.233288","name":"","topic":"domoticz/out","qos":"2","datatype":"json","broker":"f0a64cae.6413e","x":330,"y":80,"wires":[["71981d7e.1b8cd4"]]},{"id":"fea66967.f7f5a8","type":"mqtt out","z":"fe7efaec.233288","name":"","topic":"payload","qos":"","retain":"","broker":"f0a64cae.6413e","x":850,"y":400,"wires":[]},{"id":"f0a64cae.6413e","type":"mqtt-broker","z":"","name":"mosquitto","broker":"192.168.0.105","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]

it not work, and now i understand why after many trials.

with your flow we publish this message:
cmnd/tasmota_blind/shutterposition1 40

that's not correct because we do not have the payload
nodered send it out as one topic without payload.

we should send out message like this:
topic = cmnd/tasmota_blind/shutterposition1
payload = 40

so two commands made by topic+payload:
cmnd/tasmota_blind/shutterposition1 40
sorry to discover it only now :frowning:

How we can manage this?

mmm i'm tinking on it.....
for sure we need two informations inside the topic that change from one blind to another one:
the part of topic to publish and the number of blind (for example words in bold on line below)
cmnd/tasmota_blind/shutterposition1 40

but topic could be any name, not only tasmota_blind as wild card character.

what to you think if we introduce one more information inside description field?
that should become someting like:

topic=tasmota_blind
blind=1
trigger_by_nodered_blind

in bold the information that we will use in nodered.

In this case we are 100% sure that this message is for nodered and addressed to blind flow.
I'm thinking on something that could fits all needs.

if i'm learing well (hope so :-)), i think that is easy inside switch block reconize this part (trigger_by_nodered_blind) , but of course it will complicate so much the the JSONata that should clean from the string this new information, to build correctly the mqtt message.

Right now is not still clear to me how JSONata is operating.
I understand the purpose of it, but not how is operating.

ok, no problem, better to explain when we finish to have a clear picture :slight_smile:
just a question on the meantime.
are you operating using json like a string?
why not operating using like an object?
is not much easier in this way pointing directly at the descriptions field that we need?

for example inside JSONata we can just pickup the items that we need fot the output mqtt command avoiding what's not necessary, for example the new parameter inside description filed trigger_by_nodered_blind
...but maybe i'm making this soo easy / dreamin thinkin on using json as object to solve all issue :slight_smile:

Easy fix. Please see below flow.

[{"id":"23dc9ff4.66a6a","type":"inject","z":"b3412710.dacd38","name":"topic=tasmota_blind\\nblind=1","topic":"","payload":"{\"Battery\":255,\"RSSI\":12,\"description\":\"topic=tasmota_blind\\nblind=1\",\"dtype\":\"Light/Switch\",\"hwid\":\"6\",\"id\":\"000140F9\",\"idx\":169,\"name\":\"tap_tasmota_1\",\"nvalue\":2,\"stype\":\"Switch\",\"svalue1\":\"59\",\"switchType\":\"Blinds Percentage Inverted\",\"unit\":1}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":280,"y":700,"wires":[["21c32c3d.7c7ce4"]]},{"id":"8cde46f9.379ee8","type":"inject","z":"b3412710.dacd38","name":"topic=tasmota_blind2\\nblind=3","topic":"","payload":"{\"Battery\":255,\"RSSI\":12,\"description\":\"topic=tasmota_blind2\\nblind=3\",\"dtype\":\"Light/Switch\",\"hwid\":\"6\",\"id\":\"000140FB\",\"idx\":171,\"name\":\"tamp_tasmota_3\",\"nvalue\":2,\"stype\":\"Switch\",\"svalue1\":\"85\",\"switchType\":\"Blinds Percentage Inverted\",\"unit\":1}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":280,"y":760,"wires":[["21c32c3d.7c7ce4"]]},{"id":"2e8d1303.f0ae3c","type":"change","z":"b3412710.dacd38","name":"JSONata","rules":[{"t":"set","p":"part1","pt":"msg","to":"payload.description","tot":"jsonata"},{"t":"set","p":"part2","pt":"msg","to":"$replace(part1,\"\\n\", \"/\")","tot":"jsonata"},{"t":"set","p":"part3","pt":"msg","to":"$replace(part2,\"topic=\", \"cmnd/\")","tot":"jsonata"},{"t":"set","p":"topic","pt":"msg","to":"$replace(part3,\"blind=\", \"shutterposition\")","tot":"jsonata"},{"t":"set","p":"payload","pt":"msg","to":"payload.svalue1","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":660,"y":840,"wires":[["591173f7.2bdcdc"]]},{"id":"591173f7.2bdcdc","type":"debug","z":"b3412710.dacd38","name":"Replace by a MQTT out node","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":900,"y":840,"wires":[]},{"id":"4c003b81.ec8584","type":"inject","z":"b3412710.dacd38","name":"tap_tasmota_1","topic":"","payload":"{\"Battery\":255,\"RSSI\":12,\"description\":\"\",\"dtype\":\"Light/Switch\",\"id\":\"000140F9\",\"idx\":169,\"name\":\"tap_tasmota_1\",\"nvalue\":2,\"stype\":\"Switch\",\"svalue1\":\"38\",\"switchType\":\"Blinds Percentage Inverted\",\"unit\":1}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":320,"y":820,"wires":[["21c32c3d.7c7ce4"]]},{"id":"dabf9471.ab2b48","type":"inject","z":"b3412710.dacd38","name":"tap_tasmota_2","topic":"","payload":"{\"Battery\":255,\"RSSI\":12,\"description\":\"\",\"dtype\":\"Light/Switch\",\"id\":\"000140F9\",\"idx\":169,\"name\":\"tap_tasmota_2\",\"nvalue\":2,\"stype\":\"Switch\",\"svalue1\":\"38\",\"switchType\":\"Blinds Percentage Inverted\",\"unit\":1}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":320,"y":880,"wires":[["21c32c3d.7c7ce4"]]},{"id":"68f907fd.24cdb8","type":"inject","z":"b3412710.dacd38","name":"fake_tasmota_2","topic":"","payload":"{\"Battery\":255,\"RSSI\":12,\"description\":\"\",\"dtype\":\"Light/Switch\",\"id\":\"000140F9\",\"idx\":169,\"name\":\"fake_tasmota_2\",\"nvalue\":2,\"stype\":\"Switch\",\"svalue1\":\"38\",\"switchType\":\"Blinds Percentage Inverted\",\"unit\":1}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":320,"y":940,"wires":[["21c32c3d.7c7ce4"]]},{"id":"21c32c3d.7c7ce4","type":"switch","z":"b3412710.dacd38","name":"","property":"payload.description","propertyType":"msg","rules":[{"t":"cont","v":"tasmota_blind","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":510,"y":840,"wires":[["2e8d1303.f0ae3c"],["d9ba8e9f.8c6ac"]]},{"id":"d9ba8e9f.8c6ac","type":"debug","z":"b3412710.dacd38","name":"debug2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":690,"y":920,"wires":[]}]

Indeed, this will make things more complicated than necessary. I donĀ“t see how it would help exactly. We can do the routing and handling of the messages without this additional information.

Node-RED passes objects between nodes. The input data to the flow is an object and this is great as it makes everything easier. We do a single string manipulation to craft the MQTT topic you need.

Hi Andrei, first of all....it works!!!
i tested and it seams working perfectly, thanks so much!!!!

immagine

i use the first mqtt input setting is as "a prased JSON object" that's correct?

now i'm understand how work also JSONata and also how you clever divide topic and payoad for mqtt
it's enouth to name the msg.payload and msg.topic and then mqtt output will deliver the messages as it is, right?
thanks for support and sorry for make confusion on the beginning

Nice, I am happy to know.

Yes, that is correct.

Exactly, when we want to send messages via MQTT we need to create a topic and a payload. The topic creation in your specific use case is dynamic, based on the description field from the input messages. At the end of the day the flow is one of the simplest possible: just a switch node plus a change node.

now, i bit complication, partially solved but i'm stuck now
this is my flow:

[{"id":"417fbb57.f0aad4","type":"tab","label":"tapparelle_tasmota","disabled":false,"info":"per funzionare ha bisogno di compilare in domoticz il campo descrizione in questo modo:\ntopic=tasmota_blind\nblind=1\n\ndove topic = il topic in cui pubblicare, deve essere il nome che si da al nodemcu di tasmota in mqtt\ndeve essere per forza blind_tasmotaXXXXXX\nesempio: blind_tasmota oppure blind_tasmota2 blind_tasmota3 ecc ecc\n\nblind = il numero della tapparella da controllare su tasmota.\nsarebbe il numero che si pubblica in: cmnd/topic/shutterposition<x> <%>\nquindi se blind=1 userĆ  i relay1 e relay2 per muovere la tapparella 1\nse blind=2 userĆ  il relĆØ3 e relĆØ4 per muovere la tapparella 2 ecc ecc"},{"id":"666a25eb.fb66f4","type":"inject","z":"417fbb57.f0aad4","name":"topic=tasmota_blind\\nblind=1","topic":"","payload":"{\"Battery\":255,\"RSSI\":12,\"description\":\"topic=tasmota_blind\\nblind=1\",\"dtype\":\"Light/Switch\",\"hwid\":\"6\",\"id\":\"000140F9\",\"idx\":169,\"name\":\"tap_tasmota_1\",\"nvalue\":2,\"stype\":\"Switch\",\"svalue1\":\"59\",\"switchType\":\"Blinds Percentage Inverted\",\"unit\":1}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":160,"y":160,"wires":[["fe90262d.602148"]]},{"id":"366522f8.57554e","type":"inject","z":"417fbb57.f0aad4","name":"topic=tasmota_blind2\\nblind=3","topic":"","payload":"{\"Battery\":255,\"RSSI\":12,\"description\":\"topic=tasmota_blind2\\nblind=3\",\"dtype\":\"Light/Switch\",\"hwid\":\"6\",\"id\":\"000140FB\",\"idx\":171,\"name\":\"tamp_tasmota_3\",\"nvalue\":2,\"stype\":\"Switch\",\"svalue1\":\"85\",\"switchType\":\"Blinds Percentage Inverted\",\"unit\":1}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":160,"y":220,"wires":[["fe90262d.602148"]]},{"id":"c45796a3.257d1","type":"change","z":"417fbb57.f0aad4","name":"JSONata","rules":[{"t":"set","p":"part1","pt":"msg","to":"payload.description","tot":"jsonata"},{"t":"set","p":"part2","pt":"msg","to":"$replace(part1,\"\\n\", \"/\")","tot":"jsonata"},{"t":"set","p":"part3","pt":"msg","to":"$replace(part2,\"topic=\", \"cmnd/\")","tot":"jsonata"},{"t":"set","p":"topic","pt":"msg","to":"$replace(part3,\"blind=\", \"shutterposition\")","tot":"jsonata"},{"t":"set","p":"payload","pt":"msg","to":"payload.svalue1","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":540,"y":300,"wires":[["c1baa27.89591e","eb70d07e.b79f48","81cc4ebc.e731e","58ab1d41.609384"]]},{"id":"c1baa27.89591e","type":"debug","z":"417fbb57.f0aad4","name":"Replace by a MQTT out node","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":630,"y":240,"wires":[]},{"id":"9853a177.a8a68","type":"inject","z":"417fbb57.f0aad4","name":"tap_tasmota_1","topic":"","payload":"{\"Battery\":255,\"RSSI\":12,\"description\":\"\",\"dtype\":\"Light/Switch\",\"id\":\"000140F9\",\"idx\":169,\"name\":\"tap_tasmota_1\",\"nvalue\":2,\"stype\":\"Switch\",\"svalue1\":\"38\",\"switchType\":\"Blinds Percentage Inverted\",\"unit\":1}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":200,"y":280,"wires":[["fe90262d.602148"]]},{"id":"7ab15cc2.974dec","type":"inject","z":"417fbb57.f0aad4","name":"tap_tasmota_2","topic":"","payload":"{\"Battery\":255,\"RSSI\":12,\"description\":\"\",\"dtype\":\"Light/Switch\",\"id\":\"000140F9\",\"idx\":169,\"name\":\"tap_tasmota_2\",\"nvalue\":2,\"stype\":\"Switch\",\"svalue1\":\"38\",\"switchType\":\"Blinds Percentage Inverted\",\"unit\":1}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":200,"y":340,"wires":[["fe90262d.602148"]]},{"id":"1bad091c.da0d5f","type":"inject","z":"417fbb57.f0aad4","name":"fake_tasmota_2","topic":"","payload":"{\"Battery\":255,\"RSSI\":12,\"description\":\"\",\"dtype\":\"Light/Switch\",\"id\":\"000140F9\",\"idx\":169,\"name\":\"fake_tasmota_2\",\"nvalue\":2,\"stype\":\"Switch\",\"svalue1\":\"38\",\"switchType\":\"Blinds Percentage Inverted\",\"unit\":1}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":200,"y":400,"wires":[["fe90262d.602148"]]},{"id":"fe90262d.602148","type":"switch","z":"417fbb57.f0aad4","name":"","property":"payload.description","propertyType":"msg","rules":[{"t":"cont","v":"tasmota_blind","vt":"str"},{"t":"else"},{"t":"cont","v":"tasmota_master","vt":"str"}],"checkall":"true","repair":false,"outputs":3,"x":390,"y":300,"wires":[["c45796a3.257d1"],["5261eca4.d3ccac"],["ff086690.659288","61adbeec.ea4368"]]},{"id":"5261eca4.d3ccac","type":"debug","z":"417fbb57.f0aad4","name":"debug2","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":570,"y":380,"wires":[]},{"id":"eb70d07e.b79f48","type":"debug","z":"417fbb57.f0aad4","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"topic","targetType":"msg","x":560,"y":160,"wires":[]},{"id":"81cc4ebc.e731e","type":"debug","z":"417fbb57.f0aad4","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":560,"y":200,"wires":[]},{"id":"e3ef7457.d354c8","type":"mqtt in","z":"417fbb57.f0aad4","name":"","topic":"domoticz/out","qos":"2","datatype":"json","broker":"f0a64cae.6413e","x":190,"y":100,"wires":[["fe90262d.602148"]]},{"id":"58ab1d41.609384","type":"mqtt out","z":"417fbb57.f0aad4","name":"","topic":"","qos":"","retain":"","broker":"f0a64cae.6413e","x":710,"y":300,"wires":[]},{"id":"ff086690.659288","type":"change","z":"417fbb57.f0aad4","name":"JSONata_master","rules":[{"t":"set","p":"part1","pt":"msg","to":"payload.description","tot":"jsonata"},{"t":"set","p":"part2","pt":"msg","to":"$replace(part1,\"\\n\", \"/\")","tot":"jsonata"},{"t":"set","p":"part3","pt":"msg","to":"$replace(part2,\"topic=\", \"cmnd/\")","tot":"jsonata"},{"t":"set","p":"part4","pt":"msg","to":"$replace(part3,\"master\",\"blind\")","tot":"jsonata"},{"t":"set","p":"topic","pt":"msg","to":"$replace(part4,\"blind=\", \"shutterposition\")","tot":"jsonata"},{"t":"set","p":"payload","pt":"msg","to":"payload.svalue1","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":570,"y":460,"wires":[["2b281532.d65d4a","6e36eaa.4b5a514","5537b44d.7b4694"]]},{"id":"2b281532.d65d4a","type":"debug","z":"417fbb57.f0aad4","name":"debug2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":660,"y":540,"wires":[]},{"id":"41f0cf05.894c3","type":"inject","z":"417fbb57.f0aad4","name":"tasmota_blind_master","topic":"","payload":"{\"Battery\":255,\"RSSI\":12,\"description\":\"topic=tasmota_master\\nblind=1,2,3\",\"dtype\":\"Light/Switch\",\"hwid\":\"6\",\"id\":\"000140FD\",\"idx\":173,\"name\":\"tasmota_blind_master\",\"nvalue\":2,\"stype\":\"Switch\",\"svalue1\":\"76\",\"switchType\":\"Blinds Percentage Inverted\",\"unit\":1}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":200,"y":460,"wires":[["fe90262d.602148"]]},{"id":"61adbeec.ea4368","type":"debug","z":"417fbb57.f0aad4","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":440,"y":540,"wires":[]},{"id":"6e36eaa.4b5a514","type":"debug","z":"417fbb57.f0aad4","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"topic","targetType":"msg","x":660,"y":580,"wires":[]},{"id":"5537b44d.7b4694","type":"debug","z":"417fbb57.f0aad4","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":670,"y":620,"wires":[]},{"id":"f0a64cae.6413e","type":"mqtt-broker","z":"","name":"mosquitto","broker":"192.168.0.105","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]

i want to create a blind master (i put an injection in the flow with the json)

{"Battery":255,"RSSI":12,"description":"topic=tasmota_master\nblind=1,2,3","dtype":"Light/Switch","hwid":"6","id":"000140FD","idx":173,"name":"tasmota_blind_master","nvalue":2,"stype":"Switch","svalue1":"76","switchType":"Blinds Percentage Inverted","unit":1}

in this case the purpose, is: if i move this device, i want to controll all blinds and put all at same position.

i'm succeed on adding a control inside switch to recgnize thsi flow.
i creating jsonata modifing the message.
but now i'm not able to do two things:

  1. creating diffent messages for all blinds:
    cmnd/tasmota_blind/shutterposition1 76
    cmnd/tasmota_blind/shutterposition2 76
    cmnd/tasmota_blind/shutterposition3 76

  2. how to manage, different topics and conresponding number of blind?
    i guess i need to build a different desciprion field only for master blind.

because tasmota has a limitation of max 4 blind per esp8266
so if i have 10 blinds i need 3 esp8266 with 3 different topics
example:

1st esp:
cmnd/tasmota_blind/shutterposition1 76
cmnd/tasmota_blind/shutterposition2 76
cmnd/tasmota_blind/shutterposition3 76
cmnd/tasmota_blind/shutterposition4 76

2nd esp:
cmnd/tasmota_blind2/shutterposition5 76
cmnd/tasmota_blind2/shutterposition6 76
cmnd/tasmota_blind2/shutterposition7 76
cmnd/tasmota_blind2/shutterposition8 76

3rd esp:
cmnd/tasmota_blind3/shutterposition9 76
cmnd/tasmota_blind3/shutterposition10 76

maybe the description field of master_blind should be:
topic1=tasmota_blind
topic2=tasmota_blind2
topic3=tasmota_blind3
blind1=1,2,3,4
blind2=5,6,7,8
blind3=9,10

but....very complicate to manage in this way for me

It is not. Node-RED makes easy to handle and map MQTT topics.

Let me ask you a question in regards to the new requirement of a "blind master".

When you want to command more than one blind at the same time they will be always blinds connected to the same esp device ?

I want to understand if we should revise the topic structure for the MQTT topics.

Many times a good topic structure can help.

Even triggering different blinds, in different esp devices, with the same MQTT command is possible with some additional code. Better to hear from you how much flexibility you want to command the blinds.

i see the potentiality that node-red has, but still far from for me to use it :slight_smile:
every day even better, but step by step :slight_smile:
i spend hours over and over during nights and free time...but small step ahead :slight_smile:

no, they can be connected to different esp device.
max 4 blinds for each esp.
that's why i made the example with 10blinds dividen in 3 different esp.
so, with 3 different topics

example:

1st esp: this group of esp2 has topic=tasmota_blind and control blind 1-2-3-4
cmnd/tasmota_blind/shutterposition1 76
cmnd/tasmota_blind/shutterposition2 76
cmnd/tasmota_blind/shutterposition3 76
cmnd/tasmota_blind/shutterposition4 76

2nd esp: this group of esp2 has topic=tasmota_blind2 and control blind 5-6-7-8
cmnd/tasmota_blind2/shutterposition5 76
cmnd/tasmota_blind2/shutterposition6 76
cmnd/tasmota_blind2/shutterposition7 76
cmnd/tasmota_blind2/shutterposition8 76

3rd esp: this group of esp2 has topic=tasmota_blind3 and control blind 9-10
cmnd/tasmota_blind3/shutterposition9 76
cmnd/tasmota_blind3/shutterposition10 76

maybe the description field of master_blind should be:
topic1=tasmota_blind
topic2=tasmota_blind2
topic3=tasmota_blind3
blind1=1,2,3,4
blind2=5,6,7,8
blind3=9,10

sorry, not clear to me on what you mean with:

Even triggering different blinds, in different esp devices, with the same MQTT command is possible with some additional code

....i think that looking at the example, if we want to move 10 blinds at same percantage, we have to send out 10 mqtt comands:
4 mqtt comands to esp1
4 mqtt comands to esp2
2mqtt comands to esp3

maybe i do not understand what you mean...

Understood. In fact you already mentioned the solution and already made nearly half of it.

The "master" command will require that the flow sends ten MQTT commands.

This can be done by hard-coding an array of topics in the change node and using a split node to create the ten messages. Please refer to Node-RED documentation on the subject of "Working with Sequences".

This is the flow modified to implement the master functionality.

[{"id":"90d04668.7070b8","type":"inject","z":"3597c529.f604ca","name":"topic=tasmota_blind\\nblind=1","topic":"","payload":"{\"Battery\":255,\"RSSI\":12,\"description\":\"topic=tasmota_blind\\nblind=1\",\"dtype\":\"Light/Switch\",\"hwid\":\"6\",\"id\":\"000140F9\",\"idx\":169,\"name\":\"tap_tasmota_1\",\"nvalue\":2,\"stype\":\"Switch\",\"svalue1\":\"59\",\"switchType\":\"Blinds Percentage Inverted\",\"unit\":1}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":160,"y":160,"wires":[["56b3a952.319488"]]},{"id":"8b372715.b4e908","type":"inject","z":"3597c529.f604ca","name":"topic=tasmota_blind2\\nblind=3","topic":"","payload":"{\"Battery\":255,\"RSSI\":12,\"description\":\"topic=tasmota_blind2\\nblind=3\",\"dtype\":\"Light/Switch\",\"hwid\":\"6\",\"id\":\"000140FB\",\"idx\":171,\"name\":\"tamp_tasmota_3\",\"nvalue\":2,\"stype\":\"Switch\",\"svalue1\":\"85\",\"switchType\":\"Blinds Percentage Inverted\",\"unit\":1}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":160,"y":220,"wires":[["56b3a952.319488"]]},{"id":"f40293df.d7fc5","type":"change","z":"3597c529.f604ca","name":"JSONata","rules":[{"t":"set","p":"part1","pt":"msg","to":"payload.description","tot":"jsonata"},{"t":"set","p":"part2","pt":"msg","to":"$replace(part1,\"\\n\", \"/\")","tot":"jsonata"},{"t":"set","p":"part3","pt":"msg","to":"$replace(part2,\"topic=\", \"cmnd/\")","tot":"jsonata"},{"t":"set","p":"topic","pt":"msg","to":"$replace(part3,\"blind=\", \"shutterposition\")","tot":"jsonata"},{"t":"set","p":"payload","pt":"msg","to":"payload.svalue1","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":620,"y":240,"wires":[["e9896d2d.90431","b84bf875.e49d88","b4ee6db1.72a01"]]},{"id":"e9896d2d.90431","type":"debug","z":"3597c529.f604ca","name":"Replace by a MQTT out node","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":880,"y":280,"wires":[]},{"id":"f52687d1.65c928","type":"inject","z":"3597c529.f604ca","name":"tap_tasmota_1","topic":"","payload":"{\"Battery\":255,\"RSSI\":12,\"description\":\"\",\"dtype\":\"Light/Switch\",\"id\":\"000140F9\",\"idx\":169,\"name\":\"tap_tasmota_1\",\"nvalue\":2,\"stype\":\"Switch\",\"svalue1\":\"38\",\"switchType\":\"Blinds Percentage Inverted\",\"unit\":1}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":200,"y":280,"wires":[["56b3a952.319488"]]},{"id":"37cdc057.8c7bc","type":"inject","z":"3597c529.f604ca","name":"tap_tasmota_2","topic":"","payload":"{\"Battery\":255,\"RSSI\":12,\"description\":\"\",\"dtype\":\"Light/Switch\",\"id\":\"000140F9\",\"idx\":169,\"name\":\"tap_tasmota_2\",\"nvalue\":2,\"stype\":\"Switch\",\"svalue1\":\"38\",\"switchType\":\"Blinds Percentage Inverted\",\"unit\":1}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":200,"y":340,"wires":[["56b3a952.319488"]]},{"id":"c9ba3216.d86fa","type":"inject","z":"3597c529.f604ca","name":"fake_tasmota_2","topic":"","payload":"{\"Battery\":255,\"RSSI\":12,\"description\":\"\",\"dtype\":\"Light/Switch\",\"id\":\"000140F9\",\"idx\":169,\"name\":\"fake_tasmota_2\",\"nvalue\":2,\"stype\":\"Switch\",\"svalue1\":\"38\",\"switchType\":\"Blinds Percentage Inverted\",\"unit\":1}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":200,"y":400,"wires":[["56b3a952.319488"]]},{"id":"56b3a952.319488","type":"switch","z":"3597c529.f604ca","name":"","property":"payload.description","propertyType":"msg","rules":[{"t":"cont","v":"tasmota_blind","vt":"str"},{"t":"cont","v":"tasmota_master","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":3,"x":390,"y":280,"wires":[["f40293df.d7fc5","462ecdcb.e4af44"],["c7353492.541018"],["d4366496.ab2a18"]]},{"id":"d4366496.ab2a18","type":"debug","z":"3597c529.f604ca","name":"debug2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":540,"y":540,"wires":[]},{"id":"b84bf875.e49d88","type":"debug","z":"3597c529.f604ca","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"topic","targetType":"msg","x":810,"y":200,"wires":[]},{"id":"b4ee6db1.72a01","type":"debug","z":"3597c529.f604ca","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":810,"y":240,"wires":[]},{"id":"c7353492.541018","type":"change","z":"3597c529.f604ca","name":"JSONata_master","rules":[{"t":"set","p":"percentage","pt":"msg","to":"payload.svalue1","tot":"msg"},{"t":"set","p":"payload","pt":"msg","to":"[\"cmnd/tasmota_blind/shutterposition1\",\"cmnd/tasmota_blind/shutterposition2\",\"cmnd/tasmota_blind/shutterposition3\",\"cmnd/tasmota_blind/shutterposition4\",\"cmnd/tasmota_blind/shutterposition5\",\"cmnd/tasmota_blind/shutterposition6\",\"cmnd/tasmota_blind/shutterposition7\",\"cmnd/tasmota_blind/shutterposition8\",\"cmnd/tasmota_blind/shutterposition9\"]","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":630,"y":360,"wires":[["c372ec21.d3a6e"]]},{"id":"c338e855.e4bbf8","type":"debug","z":"3597c529.f604ca","name":"Connect to the MQTT out node","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":870,"y":540,"wires":[]},{"id":"a56ba743.2787b8","type":"inject","z":"3597c529.f604ca","name":"tasmota_blind_master","topic":"","payload":"{\"Battery\":255,\"RSSI\":12,\"description\":\"topic=tasmota_master\\nblind=1,2,3\",\"dtype\":\"Light/Switch\",\"hwid\":\"6\",\"id\":\"000140FD\",\"idx\":173,\"name\":\"tasmota_blind_master\",\"nvalue\":2,\"stype\":\"Switch\",\"svalue1\":\"76\",\"switchType\":\"Blinds Percentage Inverted\",\"unit\":1}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":200,"y":460,"wires":[["56b3a952.319488"]]},{"id":"462ecdcb.e4af44","type":"debug","z":"3597c529.f604ca","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":570,"y":180,"wires":[]},{"id":"c372ec21.d3a6e","type":"split","z":"3597c529.f604ca","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":710,"y":420,"wires":[["57c50aee.77ff94"]]},{"id":"57c50aee.77ff94","type":"change","z":"3597c529.f604ca","name":"","rules":[{"t":"move","p":"payload","pt":"msg","to":"topic","tot":"msg"},{"t":"set","p":"perccentage","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":780,"y":480,"wires":[["c338e855.e4bbf8"]]}]

hi, understand what you did.
is it not working.
just look at the first two messages that goes out from node "change 2 rules" (of course the others has the same problem)

{"topic":"cmnd/tasmota_blind/shutterposition6","percentage":"76","parts":{"id":"60a3a1d4.5c7f7","type":"array","count":9,"len":1,"index":5},"_msgid":"cb4de2fd.fc4b6"}
{"topic":"cmnd/tasmota_blind/shutterposition7","percentage":"76","parts":{"id":"60a3a1d4.5c7f7","type":"array","count":9,"len":1,"index":6},"_msgid":"3bff6092.8748d"}

i also put a mqtt out to test on reality


(on the right side you can see the debug that i copy-paste above.)

anyway i think that is not working because we define correctly the topic:
cmnd/tasmota_blind/shutterposition1
but not the payload, that is named percentage.
i inser two debugs at the end of node "change 2 rules". one as msg.payload and one as msg.topic
that's the first two output:

5/3/2020, 09:45:44[node: afc25c7a.8007e8](http://192.168.0.105:1880/#)cmnd/tasmota_blind/shutterposition1 : msg.topic : string[35]

"cmnd/tasmota_blind/shutterposition1"

5/3/2020, 09:45:44[node: 1f3169bf.084d46](http://192.168.0.105:1880/#)cmnd/tasmota_blind/shutterposition1 : msg.payload : undefined

undefined

5/3/2020, 09:45:44[node: afc25c7a.8007e8](http://192.168.0.105:1880/#)cmnd/tasmota_blind/shutterposition2 : msg.topic : string[35]

"cmnd/tasmota_blind/shutterposition2"

5/3/2020, 09:45:44[node: 1f3169bf.084d46](http://192.168.0.105:1880/#)

cmnd/tasmota_blind/shutterposition2 : msg.payload : undefined

undefined

it's missing the payload, right?

and a comment: we always publish at topic: tasmota_blind
i see that inside JSONata_master you define:
["cmnd/tasmota_blind/shutterposition1","cmnd/tasmota_blind/shutterposition2","cmnd/tasmota_blind/shutterposition3","cmnd/tasmota_blind/shutterposition4","cmnd/tasmota_blind/shutterposition5","cmnd/tasmota_blind/shutterposition6","cmnd/tasmota_blind/shutterposition7","cmnd/tasmota_blind/shutterposition8","cmnd/tasmota_blind/shutterposition9"]

so you create manually the comands.
it means that if i have 9 blinds like in the example i must have 3 different esp8266 (4blinds for each esp max)
so i will have:
topic1= tasmota_blind will associated to blind1= 1,2,3,4
topic2= tasmota_blind 2 will associated to blind2= 5,6,7,8
topic3= tasmota_blind3 will associate to blind3= 9

the commands should so:
["cmnd/tasmota_blind/shutterposition1","cmnd/tasmota_blind/shutterposition2","cmnd/tasmota_blind/shutterposition3","cmnd/tasmota_blind/shutterposition4","cmnd/tasmota_blind2/shutterposition5","cmnd/tasmota_blind2/shutterposition6","cmnd/tasmota_blind2/shutterposition7","cmnd/tasmota_blind2/shutterposition8","cmnd/tasmota_blind3/shutterposition9"]

it means that i will edit manually inside the node JSONata_master.
correct?

so it do not take care about what i write inside the description field inside domoticz:
topic1= tasmota_blind
topic2= tasmota_blind 2
topic3= tasmota_blind3
blind1= 1,2,3,4
blind2= 5,6,7,8
blind3= 9,10

there is a way to do this automatically, or is it much complicated?
just a curiosity, nothing else, for me is good enouht modify it manully inside JSONata_master.

anyway this is the flow, where i added some debug to test and also the injection node with the description fild with all topic and blind.

the main point now is how to set the correct messages for blind_master that now is it not working due to payload error, if i'm not wrong of course :slight_smile:
thanks

[{"id":"c83ffdda.d66cc","type":"tab","label":"Flow 3","disabled":false,"info":""},{"id":"6dccb16a.33da2","type":"inject","z":"c83ffdda.d66cc","name":"topic=tasmota_blind\\nblind=1","topic":"","payload":"{\"Battery\":255,\"RSSI\":12,\"description\":\"topic=tasmota_blind\\nblind=1\",\"dtype\":\"Light/Switch\",\"hwid\":\"6\",\"id\":\"000140F9\",\"idx\":169,\"name\":\"tap_tasmota_1\",\"nvalue\":2,\"stype\":\"Switch\",\"svalue1\":\"59\",\"switchType\":\"Blinds Percentage Inverted\",\"unit\":1}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":160,"y":100,"wires":[["15fdca4b.4089b6"]]},{"id":"9fd441d.3391ac","type":"inject","z":"c83ffdda.d66cc","name":"topic=tasmota_blind2\\nblind=3","topic":"","payload":"{\"Battery\":255,\"RSSI\":12,\"description\":\"topic=tasmota_blind2\\nblind=3\",\"dtype\":\"Light/Switch\",\"hwid\":\"6\",\"id\":\"000140FB\",\"idx\":171,\"name\":\"tamp_tasmota_3\",\"nvalue\":2,\"stype\":\"Switch\",\"svalue1\":\"85\",\"switchType\":\"Blinds Percentage Inverted\",\"unit\":1}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":160,"y":160,"wires":[["15fdca4b.4089b6"]]},{"id":"e86dbbaa.0243f8","type":"change","z":"c83ffdda.d66cc","name":"JSONata","rules":[{"t":"set","p":"part1","pt":"msg","to":"payload.description","tot":"jsonata"},{"t":"set","p":"part2","pt":"msg","to":"$replace(part1,\"\\n\", \"/\")","tot":"jsonata"},{"t":"set","p":"part3","pt":"msg","to":"$replace(part2,\"topic=\", \"cmnd/\")","tot":"jsonata"},{"t":"set","p":"topic","pt":"msg","to":"$replace(part3,\"blind=\", \"shutterposition\")","tot":"jsonata"},{"t":"set","p":"payload","pt":"msg","to":"payload.svalue1","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":620,"y":180,"wires":[["e491745f.2e54e","8cb6ef1c.07c81","b356c6ad.dabed8","445fdba8.7e4e4c"]]},{"id":"e491745f.2e54e","type":"debug","z":"c83ffdda.d66cc","name":"Replace by a MQTT out node","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":880,"y":220,"wires":[]},{"id":"f2475f69.deccf8","type":"inject","z":"c83ffdda.d66cc","name":"tap_tasmota_1","topic":"","payload":"{\"Battery\":255,\"RSSI\":12,\"description\":\"\",\"dtype\":\"Light/Switch\",\"id\":\"000140F9\",\"idx\":169,\"name\":\"tap_tasmota_1\",\"nvalue\":2,\"stype\":\"Switch\",\"svalue1\":\"38\",\"switchType\":\"Blinds Percentage Inverted\",\"unit\":1}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":200,"y":220,"wires":[["15fdca4b.4089b6"]]},{"id":"3eeb7624.32540a","type":"inject","z":"c83ffdda.d66cc","name":"tap_tasmota_2","topic":"","payload":"{\"Battery\":255,\"RSSI\":12,\"description\":\"\",\"dtype\":\"Light/Switch\",\"id\":\"000140F9\",\"idx\":169,\"name\":\"tap_tasmota_2\",\"nvalue\":2,\"stype\":\"Switch\",\"svalue1\":\"38\",\"switchType\":\"Blinds Percentage Inverted\",\"unit\":1}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":200,"y":280,"wires":[["15fdca4b.4089b6"]]},{"id":"2345a2f1.4bc306","type":"inject","z":"c83ffdda.d66cc","name":"fake_tasmota_2","topic":"","payload":"{\"Battery\":255,\"RSSI\":12,\"description\":\"\",\"dtype\":\"Light/Switch\",\"id\":\"000140F9\",\"idx\":169,\"name\":\"fake_tasmota_2\",\"nvalue\":2,\"stype\":\"Switch\",\"svalue1\":\"38\",\"switchType\":\"Blinds Percentage Inverted\",\"unit\":1}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":200,"y":340,"wires":[["15fdca4b.4089b6"]]},{"id":"15fdca4b.4089b6","type":"switch","z":"c83ffdda.d66cc","name":"","property":"payload.description","propertyType":"msg","rules":[{"t":"cont","v":"tasmota_blind","vt":"str"},{"t":"cont","v":"tasmota_master","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":3,"x":390,"y":220,"wires":[["e86dbbaa.0243f8","98e5bf3c.b5b28"],["b3b9301f.59f9d","47743c5e.71f02c"],["6c5dcf0d.26e81"]]},{"id":"6c5dcf0d.26e81","type":"debug","z":"c83ffdda.d66cc","name":"messages not for blinds","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":550,"y":540,"wires":[]},{"id":"8cb6ef1c.07c81","type":"debug","z":"c83ffdda.d66cc","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"topic","targetType":"msg","x":810,"y":140,"wires":[]},{"id":"b356c6ad.dabed8","type":"debug","z":"c83ffdda.d66cc","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":810,"y":180,"wires":[]},{"id":"b3b9301f.59f9d","type":"change","z":"c83ffdda.d66cc","name":"JSONata_master","rules":[{"t":"set","p":"percentage","pt":"msg","to":"payload.svalue1","tot":"msg"},{"t":"set","p":"payload","pt":"msg","to":"[\"cmnd/tasmota_blind/shutterposition1\",\"cmnd/tasmota_blind/shutterposition2\",\"cmnd/tasmota_blind/shutterposition3\",\"cmnd/tasmota_blind/shutterposition4\",\"cmnd/tasmota_blind/shutterposition5\",\"cmnd/tasmota_blind/shutterposition6\",\"cmnd/tasmota_blind/shutterposition7\",\"cmnd/tasmota_blind/shutterposition8\",\"cmnd/tasmota_blind/shutterposition9\"]","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":630,"y":300,"wires":[["6fbea2e6.279f64"]]},{"id":"5784ad7d.5392f4","type":"debug","z":"c83ffdda.d66cc","name":"Connect to the MQTT out node","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":870,"y":480,"wires":[]},{"id":"b186d908.c5dea","type":"inject","z":"c83ffdda.d66cc","name":"tasmota_blind_master","topic":"","payload":"{\"Battery\":255,\"RSSI\":12,\"description\":\"topic=tasmota_master\\nblind=1,2,3\",\"dtype\":\"Light/Switch\",\"hwid\":\"6\",\"id\":\"000140FD\",\"idx\":173,\"name\":\"tasmota_blind_master\",\"nvalue\":2,\"stype\":\"Switch\",\"svalue1\":\"76\",\"switchType\":\"Blinds Percentage Inverted\",\"unit\":1}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":200,"y":400,"wires":[["15fdca4b.4089b6"]]},{"id":"98e5bf3c.b5b28","type":"debug","z":"c83ffdda.d66cc","name":"single blind","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":590,"y":120,"wires":[]},{"id":"6fbea2e6.279f64","type":"split","z":"c83ffdda.d66cc","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":710,"y":360,"wires":[["371b52ac.dc30d6"]]},{"id":"371b52ac.dc30d6","type":"change","z":"c83ffdda.d66cc","name":"","rules":[{"t":"move","p":"payload","pt":"msg","to":"topic","tot":"msg"},{"t":"set","p":"perccentage","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":780,"y":420,"wires":[["5784ad7d.5392f4","afc25c7a.8007e8","1f3169bf.084d46","84df2b59.80e4f8"]]},{"id":"90a9c02c.af3cb8","type":"mqtt in","z":"c83ffdda.d66cc","name":"","topic":"domoticz/out","qos":"2","datatype":"json","broker":"f0a64cae.6413e","x":230,"y":40,"wires":[["15fdca4b.4089b6"]]},{"id":"445fdba8.7e4e4c","type":"mqtt out","z":"c83ffdda.d66cc","name":"","topic":"","qos":"","retain":"","broker":"f0a64cae.6413e","x":930,"y":300,"wires":[]},{"id":"1f3169bf.084d46","type":"debug","z":"c83ffdda.d66cc","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":830,"y":560,"wires":[]},{"id":"afc25c7a.8007e8","type":"debug","z":"c83ffdda.d66cc","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"topic","targetType":"msg","x":830,"y":520,"wires":[]},{"id":"47743c5e.71f02c","type":"debug","z":"c83ffdda.d66cc","name":"blind master","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":550,"y":480,"wires":[]},{"id":"84df2b59.80e4f8","type":"mqtt out","z":"c83ffdda.d66cc","name":"","topic":"","qos":"","retain":"","broker":"f0a64cae.6413e","x":980,"y":420,"wires":[]},{"id":"450dd446.9b79cc","type":"inject","z":"c83ffdda.d66cc","name":"tasmota_blind_master_all_topic_declared","topic":"","payload":"{\"Battery\":255,\"RSSI\":12,\"description\":\"tasmota_master\\ntopic1=tasmota_blind\\ntopic2=tasmota_blind2\\ntopic3=tasmota_blind3\\nblind1=1,2,3,4\\nblind2=5,6,7,8\\nblind3=9,10\",\"dtype\":\"Light/Switch\",\"hwid\":\"6\",\"id\":\"000140FD\",\"idx\":173,\"name\":\"tasmota_blind_master\",\"nvalue\":2,\"stype\":\"Switch\",\"svalue1\":\"58\",\"switchType\":\"Blinds Percentage Inverted\",\"unit\":1}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":220,"y":460,"wires":[["15fdca4b.4089b6"]]},{"id":"f0a64cae.6413e","type":"mqtt-broker","z":"","name":"mosquitto","broker":"192.168.0.105","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]

Exactly. There are a couple of mistakes on the the last rule in change node named "change: 2 rules". Correct the typo and change from set to move and it should work.

a-02

Correct too. I copy and pasted in hurry. You can edit this part of the code to fix. This is a flexible approach as you can define in a single array what blinds you want to activate with the master command. I imagine you can use the same idea to create different "scenarios" where you define which blinds you want to command.

Too much complicated indeed.

Hi Andrei, thanks so much for you kindness, now all woks !
thank you!!!
Marco

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.