He meant you need to replace the switch node with a change node.
With a change node you will change/replace the payload value with the payload.temperature value, which means the debug node that is currently set to payload will display the temperature and not an object.
Alternatively you could ditch the change node altogether and just have the debug node output msg.payload.temperature rather than msg.payload
Please reload my flow above, you left out the split node. The split node is needed before the switch.
In my opinion, using the split only makes your life harder.
When you split a message you can only work with that part of the message.
If a condition is temperature is above x and humidity above y then it will be show stopper for you.
However as long as you keep the message as one then any part can be used to any purpose independently.
It won’t be harder to use the complete message, just different.
I still have not yet seen anything where the message is used except a debug, or understood what the end purpose is.
If you tell us what you want then I believe we can help you.
I don’t know how to break out the temp value after the json node without spiting it to isolate the value. OP wants the temperature value to send to the blynk app.
Hi @Hellis81 @nicp and @Mikefila… Here’s what I implemented and it is working… sort of. I am successfully sending the temperature data to the Blynk app, but haven’t figured out how to extract something like the humidity. Which I suspect is where @nicp is going.
Ultimately I’d like to be able to extract the individual elements contained within msg.payload, which I suspect may require a switch node to redirect the data? Or am I looking in the wrong place?
I think this way is overly complex. You can easily read any part of the message with the change node (or many other nodes for that matter)
Just add another change node. move msg.payload.humidity.
Wire it from the same place as the existing move.msg.payload.temperature so they are in parallel
Hi Nic,
Thanks for that, will give it a go. I am also trying it with a switch… See below. Hasn’t fired an update yet, but waiting to see if a switch node can split the temperature and humidity data.
Scratch that… it didn’t work.
I see now what you are saying but I’d rather deal with the string once by either breaking them all out to their own entities.
[{"id":"771b68341fadda12","type":"inject","z":"f80b6c338afd5483","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"battery\":100,\"humidity\":56.09,\"linkquality\":111,\"pressure\":1040,\"temperature\":21.35,\"voltage\":3065}","payloadType":"str","x":1170,"y":1640,"wires":[["cb927698e53d4ee3"]]},{"id":"cb927698e53d4ee3","type":"json","z":"f80b6c338afd5483","name":"","property":"payload","action":"","pretty":false,"x":1290,"y":1640,"wires":[["57d0f9207e2b3d59"]]},{"id":"d9fac208e56f6bd8","type":"switch","z":"f80b6c338afd5483","name":"","property":"parts.key","propertyType":"msg","rules":[{"t":"eq","v":"battery","vt":"str"},{"t":"eq","v":"humidity","vt":"str"},{"t":"eq","v":"linkquality","vt":"str"},{"t":"eq","v":"pressure","vt":"str"},{"t":"eq","v":"temperature","vt":"str"},{"t":"eq","v":"voltage","vt":"str"}],"checkall":"true","repair":false,"outputs":6,"x":1530,"y":1640,"wires":[["dad81378cda15142"],["74fcc9063ffa8fb0"],["8863ba4708504610"],["28fb47ed3ee07534"],["9f034dcd0f44d37b"],["6b1c57062451ce61"]]},{"id":"57d0f9207e2b3d59","type":"split","z":"f80b6c338afd5483","name":"","splt":"\\n","spltType":"str","arraySplt":"2","arraySpltType":"len","stream":false,"addname":"","x":1410,"y":1640,"wires":[["d9fac208e56f6bd8"]]},{"id":"28fb47ed3ee07534","type":"ha-entity","z":"f80b6c338afd5483","name":"pressure","server":"","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":""},{"property":"device_class","value":""},{"property":"icon","value":""},{"property":"unit_of_measurement","value":""}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"payload","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":1760,"y":1640,"wires":[[]]},{"id":"74fcc9063ffa8fb0","type":"ha-entity","z":"f80b6c338afd5483","name":"humidity","server":"","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":""},{"property":"device_class","value":""},{"property":"icon","value":""},{"property":"unit_of_measurement","value":""}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"payload","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":1760,"y":1560,"wires":[[]]},{"id":"dad81378cda15142","type":"ha-entity","z":"f80b6c338afd5483","name":"battery","server":"","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":""},{"property":"device_class","value":""},{"property":"icon","value":""},{"property":"unit_of_measurement","value":""}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"payload","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":1750,"y":1520,"wires":[[]]},{"id":"8863ba4708504610","type":"ha-entity","z":"f80b6c338afd5483","name":"link quality","server":"","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":""},{"property":"device_class","value":""},{"property":"icon","value":""},{"property":"unit_of_measurement","value":""}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"payload","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":1770,"y":1600,"wires":[[]]},{"id":"6b1c57062451ce61","type":"ha-entity","z":"f80b6c338afd5483","name":"voltage","server":"","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":""},{"property":"device_class","value":""},{"property":"icon","value":""},{"property":"unit_of_measurement","value":""}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"payload","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":1760,"y":1720,"wires":[[]]},{"id":"9f034dcd0f44d37b","type":"ha-entity","z":"f80b6c338afd5483","name":"temperature","server":"","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":""},{"property":"device_class","value":""},{"property":"icon","value":""},{"property":"unit_of_measurement","value":""}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"payload","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":1770,"y":1680,"wires":[[]]}]
Or a more light weight way to do it would be just to republish each value on it’s own topic.
[{"id":"f91c0961d1a8d7db","type":"inject","z":"f80b6c338afd5483","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"battery\":100,\"humidity\":56.09,\"linkquality\":111,\"pressure\":1040,\"temperature\":21.35,\"voltage\":3065}","payloadType":"str","x":1310,"y":1420,"wires":[["b90d7aac8a1d1fc9"]]},{"id":"b90d7aac8a1d1fc9","type":"json","z":"f80b6c338afd5483","name":"","property":"payload","action":"","pretty":false,"x":1430,"y":1420,"wires":[["cd06f8394aa0b2e3"]]},{"id":"cd06f8394aa0b2e3","type":"split","z":"f80b6c338afd5483","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":1550,"y":1420,"wires":[["57ac2690e48e2523"]]},{"id":"8f05829fe5a1698a","type":"mqtt out","z":"f80b6c338afd5483","name":"","topic":"","qos":"","retain":"","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"601bef1.d5b981","x":1850,"y":1420,"wires":[]},{"id":"57ac2690e48e2523","type":"change","z":"f80b6c338afd5483","name":"","rules":[{"t":"set","p":"x","pt":"msg","to":"mysensor/#","tot":"str"},{"t":"change","p":"x","pt":"msg","from":"#","fromt":"str","to":"parts.key","tot":"msg"},{"t":"move","p":"x","pt":"msg","to":"topic","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1700,"y":1420,"wires":[["8f05829fe5a1698a"]]},{"id":"601bef1.d5b981","type":"mqtt-broker","name":"Mosquitto","broker":"127.0.0.1","port":"1883","clientid":"","autoConnect":true,"usetls":false,"protocolVersion":4,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]
Can you just show me what the green HouseTemp config is.
I don’t know what that node is or what it does.
You won’t need to split or change, all parts of the message is there you just need to read them.
I only need to know what you are doing with the data
Hi @Hellis81, see my very first post, which contains the raw data that comes from the MQTT node labelled HouseTemp. That is the data I receive via MQTT, and the data I am filtering to individual elements, such as temperature, humidity, etc.
But that is not the green HouseTemp node.
I need to know what you are doing with the message. What is the config in the last node.
Not much going on in the last node…
That node is the interface to the Blynk app, and pretty much accepts whatever it is supplied by the nodes in front of it. The particular Blynk Virtual Pin is configured as a temperature guage, so it is expecting to receive numbers.
So what does this node do then?
I don’t understand what Blynk is or what it does.
Does it only take the payload or can it be configured? What does it do?
What do you want it to do?
Sorry I see now that you edited.
Here is what the Blynk app looks like on my phone… the data we are discussing is feeding the temperature gauge circled in red.
Essentially all the nodes prior to the last green Blynk node prepare the data in a format the Blynk app can understand.
So if I understand it correctly the Blynk node can only take the payload and can’t be configured for anything more advanced.
In that case the change node is the only option that is good in my opinion, not that it’s great either.
Give me a few minutes and I will create a sequence.
This should work.
Since I don’t have the MQTT input I have used an inject, and I don’t have Blynk I had to use current state nodes as “placeholders”.
Just replace these with the input and Blynk output nodes.
The first change node does two actions. First it change place of the json data to msg.json to preserve it, then it replaces the payload with the temperature.
The second change node takes the msg.json.humidity and sets that to the payload so that the second Blynk node gets the humidity
[{"id":"7cd1dcb798fa9cba","type":"change","z":"14ca354715bc92f3","name":"","rules":[{"t":"set","p":"json","pt":"msg","to":"payload","tot":"msg"},{"t":"set","p":"payload","pt":"msg","to":"json.temperature","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":580,"y":660,"wires":[["1e708e8fbfbabc81"]]},{"id":"b1664fd5d8d9d187","type":"json","z":"14ca354715bc92f3","name":"","property":"payload","action":"","pretty":false,"x":420,"y":660,"wires":[["7cd1dcb798fa9cba"]]},{"id":"1e708e8fbfbabc81","type":"api-current-state","z":"14ca354715bc92f3","name":"BLYNK node Temp","server":"4bbca37b.1700ec","version":2,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"","state_type":"str","blockInputOverrides":false,"outputProperties":[],"override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":790,"y":660,"wires":[["d75784687235790b"]]},{"id":"f91c0961d1a8d7db","type":"inject","z":"14ca354715bc92f3","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"battery\":100,\"humidity\":56.09,\"linkquality\":111,\"pressure\":1040,\"temperature\":21.35,\"voltage\":3065}","payloadType":"str","x":250,"y":660,"wires":[["b1664fd5d8d9d187"]]},{"id":"d75784687235790b","type":"change","z":"14ca354715bc92f3","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"json.humidity","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":980,"y":660,"wires":[["7640cea4483f0ae4"]]},{"id":"7640cea4483f0ae4","type":"api-current-state","z":"14ca354715bc92f3","name":"BLYNK node Humidity","server":"4bbca37b.1700ec","version":2,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"","state_type":"str","blockInputOverrides":false,"outputProperties":[],"override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":1200,"y":660,"wires":[["ed0a70bcd258ea58"]]},{"id":"ed0a70bcd258ea58","type":"debug","z":"14ca354715bc92f3","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1390,"y":660,"wires":[]},{"id":"4bbca37b.1700ec","type":"server","name":"Home Assistant","version":1,"legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]
Another option is to do like this instead:
This does the actions in parallell instead of inline. This is probably a better solution since if one Blynk node errors the rest won’t get the message in the other version, but since this works in parallell each node will work independent of each other.
[{"id":"b1664fd5d8d9d187","type":"json","z":"14ca354715bc92f3","name":"","property":"payload","action":"","pretty":false,"x":420,"y":660,"wires":[["7cd1dcb798fa9cba"]]},{"id":"f91c0961d1a8d7db","type":"inject","z":"14ca354715bc92f3","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"battery\":100,\"humidity\":56.09,\"linkquality\":111,\"pressure\":1040,\"temperature\":21.35,\"voltage\":3065}","payloadType":"str","x":250,"y":660,"wires":[["b1664fd5d8d9d187"]]},{"id":"7cd1dcb798fa9cba","type":"change","z":"14ca354715bc92f3","name":"","rules":[{"t":"set","p":"json","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":570,"y":660,"wires":[["88ca11ccd883e4a2","d75784687235790b"]]},{"id":"88ca11ccd883e4a2","type":"change","z":"14ca354715bc92f3","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"json.temperature","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":780,"y":560,"wires":[["1e708e8fbfbabc81"]]},{"id":"d75784687235790b","type":"change","z":"14ca354715bc92f3","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"json.humidity","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":780,"y":660,"wires":[["7640cea4483f0ae4"]]},{"id":"1e708e8fbfbabc81","type":"api-current-state","z":"14ca354715bc92f3","name":"BLYNK node Temp","server":"4bbca37b.1700ec","version":2,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"","state_type":"str","blockInputOverrides":false,"outputProperties":[],"override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":970,"y":560,"wires":[[]]},{"id":"7640cea4483f0ae4","type":"api-current-state","z":"14ca354715bc92f3","name":"BLYNK node Humidity","server":"4bbca37b.1700ec","version":2,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"","state_type":"str","blockInputOverrides":false,"outputProperties":[],"override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":980,"y":660,"wires":[[]]},{"id":"4bbca37b.1700ec","type":"server","name":"Home Assistant","version":1,"legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]
The beauty of using the complete message is that you now can condition other parts of the message before sending to Blynk.
Obviously a stupid example, but only if the battery is above 50% send the temperature to Blynk.
But you get the idea, now we can make conditions and do stuff based on other parts of the json except the temperature in the “temperature branch”