To send data to my EasyIO

Good afternoon everyone,

i'm looking for a little help have already tried several things but can't figure it out.

if I use my slider to adjust the temperature, I get the data neatly, if I then want to send the actual temperature an error message appears ... what am I doing wrong

image

there is a lot of talk about float and found the following about it

i = msg.payload;
v = i. toFixed(2);
msg.payload = '{"tempjas": ' + v + '}';
return msg;

image

Number.prototype.toFixed() - JavaScript | MDN (mozilla.org)

toFixed needs a number, you've probably passed a string. Check with a debug output or put a statement like node.warn(typeof msg.payload) in your function node.

Also, why are you creating a string that looks like JSON? Why not just create a javascript object?

Finally, please post code to the forum as a code block not as text as that is hard to read and cannot always be copied if someone wants to test it.

It's my first post sorry

I should have placed the code correctly now

it is indeed a string

and Java, Fine it's about the end result

[{"id":"6fc9b99a.38c178","type":"function","z":"5d5dca67.b32764","name":"tempjas","func":"node.warn(typeof msg.payload)\ni = msg.payload;\nv = i. toFixed(2);\nmsg.payload = '{\"tempjas\": ' + v + '}';\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":700,"y":820,"wires":[["e0eb5f2c.44dbf","9462bbb1.7cfa68"]]}]

I turned it into java and indeed more is coming out

image

[{"id":"6e507e50.2949e","type":"mqtt in","z":"5d5dca67.b32764","name":"","topic":"/wens/#","qos":"0","datatype":"auto","broker":"8054fcea.8694a","x":1030,"y":1040,"wires":[["41beb79.62e3948"]]},{"id":"41beb79.62e3948","type":"debug","z":"5d5dca67.b32764","name":"TEST","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1150,"y":1040,"wires":[]},{"id":"de272bd0.621a68","type":"function","z":"5d5dca67.b32764","name":"THB","func":"var T = msg.payload.svalue1;\nvar H = msg.payload.svalue2;\nvar B = msg.payload.svalue4;\n\nreturn[{payload:T},{payload:H},{payload:B}]","outputs":3,"noerr":0,"initialize":"","finalize":"","x":530,"y":920,"wires":[["68701b01.51ebc4","8a1fdc7.c4f3e2"],["3fb6f6fd.fca2da"],[]]},{"id":"68701b01.51ebc4","type":"ui_gauge","z":"5d5dca67.b32764","name":"","group":"ead8193c.611128","order":6,"width":0,"height":0,"gtype":"donut","title":"Jasmijn °C","label":"°C","format":"{{value}}","min":"15","max":"25","colors":["#004cff","#c800ff","#ff0000"],"seg1":"","seg2":"","x":710,"y":880,"wires":[]},{"id":"3fb6f6fd.fca2da","type":"ui_gauge","z":"5d5dca67.b32764","name":"","group":"ead8193c.611128","order":8,"width":0,"height":0,"gtype":"donut","title":"Jasmijn rv","label":"%","format":"{{value}}","min":"15","max":"100","colors":["#004cff","#c800ff","#ff0000"],"seg1":"","seg2":"","x":700,"y":940,"wires":[]},{"id":"c00cb76e.d47a28","type":"mqtt out","z":"5d5dca67.b32764","name":"","topic":"/wens/tempjas/","qos":"","retain":"","broker":"8054fcea.8694a","x":880,"y":1040,"wires":[]},{"id":"e0eb5f2c.44dbf","type":"debug","z":"5d5dca67.b32764","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":870,"y":1000,"wires":[]},{"id":"8a1fdc7.c4f3e2","type":"yaml","z":"5d5dca67.b32764","property":"payload","name":"","x":710,"y":1020,"wires":[["c00cb76e.d47a28","e0eb5f2c.44dbf"]]},{"id":"8054fcea.8694a","type":"mqtt-broker","name":"","broker":"192.168.78.60","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"ead8193c.611128","type":"ui_group","name":"","tab":"5f1f01f2.d09d","order":1,"disp":false,"width":5,"collapse":false},{"id":"5f1f01f2.d09d","type":"ui_tab","name":"Home","icon":"dashboard","order":1,"disabled":false,"hidden":false}]

Hi Robert,

I use the EasyIO Controllers also but i havent tried their MQTT capabilities yet.

When you post on the forum use this icon
image

so your flow and code will be correctly formatted

Use the pencil icon image to re-edit your post and correct it .. otherwise we cannot import it.

I know nothing about your system but regarding your MQTT topics - never start or end a topic with a / While a leading slash will work, it is simply not recommended as it just creates an empty 1st level topic. As for trailing slash, this would create an empty subtopic (probably doesnt play nice on some brokers)

In simple terms, change your topic to wens/tempjas

Thank you very much man,

EasyIO is the best controller out there right now for this money
I am a supplier in NL
Thanks for the explanation, I am not too handy with forums yet

thanks as far as I can see the data about MQTT is neat but my EasyIO controller does not handle this yet
I just have to look a little further

good afternoon
I am still puzzling
I have as you indicated adjusted the topic and a yaml in between but still get no result

[{"id":"6e507e50.2949e","type":"mqtt in","z":"5d5dca67.b32764","name":"","topic":"wens/#","qos":"0","datatype":"auto","broker":"8054fcea.8694a","x":1030,"y":1000,"wires":[["41beb79.62e3948"]]},{"id":"41beb79.62e3948","type":"debug","z":"5d5dca67.b32764","name":"TEST","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1150,"y":1000,"wires":[]},{"id":"440872c8.6e6ddc","type":"mqtt in","z":"5d5dca67.b32764","name":"","topic":"domoticz/#","qos":"0","datatype":"auto","broker":"4c8c4bc3.838e34","x":80,"y":940,"wires":[["63a39a1f.1348e4"]]},{"id":"63a39a1f.1348e4","type":"json","z":"5d5dca67.b32764","name":"","property":"payload","action":"","pretty":false,"x":210,"y":940,"wires":[["2226c00b.f84f7"]]},{"id":"2226c00b.f84f7","type":"switch","z":"5d5dca67.b32764","name":"Smart","property":"payload.idx","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"str"},{"t":"eq","v":"280","vt":"str"},{"t":"eq","v":"358","vt":"str"},{"t":"eq","v":"605","vt":"str"},{"t":"eq","v":"486","vt":"str"},{"t":"eq","v":"17","vt":"str"},{"t":"eq","v":"20","vt":"str"},{"t":"eq","v":"627","vt":"str"},{"t":"eq","v":"31","vt":"str"},{"t":"eq","v":"629","vt":"str"},{"t":"eq","v":"630","vt":"str"},{"t":"eq","v":"485","vt":"str"},{"t":"eq","v":"491","vt":"str"},{"t":"eq","v":"59","vt":"str"},{"t":"eq","v":"615","vt":"str"},{"t":"eq","v":"1162","vt":"str"}],"checkall":"true","repair":false,"outputs":16,"x":330,"y":940,"wires":[["de272bd0.621a68"],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]]},{"id":"de272bd0.621a68","type":"function","z":"5d5dca67.b32764","name":"THB","func":"var T = msg.payload.svalue1;\nvar H = msg.payload.svalue2;\nvar B = msg.payload.svalue4;\n\nreturn[{payload:T},{payload:H},{payload:B}]","outputs":3,"noerr":0,"initialize":"","finalize":"","x":470,"y":820,"wires":[["68701b01.51ebc4","97ed9863.2b47a8","94bab10e.ffa6c"],["3fb6f6fd.fca2da"],[]]},{"id":"68701b01.51ebc4","type":"ui_gauge","z":"5d5dca67.b32764","name":"","group":"ead8193c.611128","order":6,"width":0,"height":0,"gtype":"donut","title":"Jasmijn °C","label":"°C","format":"{{value}}","min":"15","max":"25","colors":["#004cff","#c800ff","#ff0000"],"seg1":"","seg2":"","x":650,"y":800,"wires":[]},{"id":"3fb6f6fd.fca2da","type":"ui_gauge","z":"5d5dca67.b32764","name":"","group":"ead8193c.611128","order":8,"width":0,"height":0,"gtype":"donut","title":"Jasmijn rv","label":"%","format":"{{value}}","min":"15","max":"100","colors":["#004cff","#c800ff","#ff0000"],"seg1":"","seg2":"","x":640,"y":840,"wires":[]},{"id":"c00cb76e.d47a28","type":"mqtt out","z":"5d5dca67.b32764","name":"","topic":"","qos":"","retain":"","broker":"8054fcea.8694a","x":890,"y":1000,"wires":[]},{"id":"e0eb5f2c.44dbf","type":"debug","z":"5d5dca67.b32764","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":990,"y":1100,"wires":[]},{"id":"8a1fdc7.c4f3e2","type":"yaml","z":"5d5dca67.b32764","property":"payload","name":"","x":710,"y":1060,"wires":[[]]},{"id":"97ed9863.2b47a8","type":"function","z":"5d5dca67.b32764","name":"","func":"msg.payload = { \"wens/tempjas\" : msg.payload };\nreturn msg","outputs":1,"noerr":0,"initialize":"","finalize":"","x":540,"y":1060,"wires":[["8a1fdc7.c4f3e2"]]},{"id":"94bab10e.ffa6c","type":"function","z":"5d5dca67.b32764","name":"","func":"msg.payload = { \"wens/tempjas\" : msg.payload };\nreturn msg","outputs":1,"noerr":0,"initialize":"","finalize":"","x":540,"y":1100,"wires":[["2ef81b84.9ce574"]]},{"id":"2ef81b84.9ce574","type":"yaml","z":"5d5dca67.b32764","property":"payload","name":"","x":710,"y":1100,"wires":[["c00cb76e.d47a28","e0eb5f2c.44dbf"]]},{"id":"8054fcea.8694a","type":"mqtt-broker","name":"","broker":"192.168.78.60","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"4c8c4bc3.838e34","type":"mqtt-broker","name":"Meterkast","broker":"192.168.78.20","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"ead8193c.611128","type":"ui_group","name":"","tab":"5f1f01f2.d09d","order":1,"disp":false,"width":5,"collapse":false},{"id":"5f1f01f2.d09d","type":"ui_tab","name":"Home","icon":"dashboard","order":1,"disabled":false,"hidden":false}]

Hi, as you provide no sample data for domoticz/# i have no idea what is supposed to be happening.

Obvious errors...

In the 2nd function, you do this...

msg.payload = { "wens/tempjas" : msg.payload };
return msg

you should do this...

//msg.payload =  //<<< no need to set payload, you did that in function 1
msg.topic = "wens/tempjas"; //<< Set the topic of the msg.
return msg

... or use a change node to set topic (see my demo flow below)

Strange stuff...

Are you REALLY wanting to send YAML formatted data to MQTT? I suspect NOT - just delete it and let the topic + payload be sent

Try this flow...

[{"id":"7918ee92.f0326","type":"mqtt in","z":"c0d29384.b346c","name":"","topic":"wens/#","qos":"0","datatype":"auto","broker":"58905bb1.6acb74","x":710,"y":220,"wires":[["b8d56753.2a3da8"]]},{"id":"b8d56753.2a3da8","type":"debug","z":"c0d29384.b346c","name":"TEST","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":850,"y":220,"wires":[]},{"id":"28bb6bd3.c44a44","type":"mqtt in","z":"c0d29384.b346c","name":"","topic":"domoticz/#","qos":"0","datatype":"json","broker":"68bc0885.f2d258","x":140,"y":240,"wires":[["b35a10d.7f3c6f","5fb2021b.13e87c"]]},{"id":"5fb2021b.13e87c","type":"switch","z":"c0d29384.b346c","name":"Smart","property":"payload.idx","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"str"},{"t":"eq","v":"280","vt":"str"},{"t":"eq","v":"358","vt":"str"},{"t":"eq","v":"605","vt":"str"},{"t":"eq","v":"486","vt":"str"},{"t":"eq","v":"17","vt":"str"},{"t":"eq","v":"20","vt":"str"},{"t":"eq","v":"627","vt":"str"},{"t":"eq","v":"31","vt":"str"},{"t":"eq","v":"629","vt":"str"},{"t":"eq","v":"630","vt":"str"},{"t":"eq","v":"485","vt":"str"},{"t":"eq","v":"491","vt":"str"},{"t":"eq","v":"59","vt":"str"},{"t":"eq","v":"615","vt":"str"},{"t":"eq","v":"1162","vt":"str"}],"checkall":"true","repair":false,"outputs":16,"x":310,"y":240,"wires":[["92e8df6f.419c"],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]]},{"id":"92e8df6f.419c","type":"function","z":"c0d29384.b346c","name":"THB","func":"var T = msg.payload.svalue1;\nvar H = msg.payload.svalue2;\nvar B = msg.payload.svalue4;\n\nreturn[{payload:T},{payload:H},{payload:B}]","outputs":3,"noerr":0,"initialize":"","finalize":"","x":450,"y":140,"wires":[["8fd1309.6d16dd"],[],[]]},{"id":"b583d21c.b1141","type":"mqtt out","z":"c0d29384.b346c","name":"","topic":"","qos":"","retain":"","broker":"58905bb1.6acb74","x":850,"y":120,"wires":[]},{"id":"8a4d82e3.8d254","type":"debug","z":"c0d29384.b346c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":870,"y":160,"wires":[]},{"id":"b35a10d.7f3c6f","type":"debug","z":"c0d29384.b346c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":170,"y":280,"wires":[]},{"id":"8fd1309.6d16dd","type":"change","z":"c0d29384.b346c","name":"set topic to wens/tempjas","rules":[{"t":"set","p":"topic","pt":"msg","to":"wens/tempjas","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":650,"y":120,"wires":[["b583d21c.b1141","8a4d82e3.8d254"]]},{"id":"58905bb1.6acb74","type":"mqtt-broker","name":"","broker":"192.168.78.60","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"68bc0885.f2d258","type":"mqtt-broker","name":"Meterkast","broker":"192.168.78.20","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]

Yes .. they are amazing .. especially the new FS32 & FS20 series are a great improvement to speed .. many inputs outputs and the way they are programmed is very easy .. wiring pieces of logic together like in Node-red .. the concept is quite revolutionary. Of course it doesnt come close to NRs capabilities in programming :wink:


May i add .. like in this case that we dont have your MQTT in node, we dont know what msgs come out of it ... you can capture a few messages by adding a Debug node after it and set it to
image
and from the Debug window use the Copy value icon to copy the 'root' of the msg in order to post on the forum.

image

Im sure if you follow Steve's suggestions you'll have it working.

Good afternoon everyone,

IT WORKED
with a small adjustment

thank you very much for the support

[{"id":"8a4d82e3.8d254","type":"debug","z":"5d5dca67.b32764","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1110,"y":820,"wires":[]},{"id":"2ca952f2.9e6f9e","type":"mqtt out","z":"5d5dca67.b32764","name":"Pi4","topic":"","qos":"","retain":"","broker":"8054fcea.8694a","x":1250,"y":760,"wires":[]},{"id":"dd3ecf27.74337","type":"function","z":"5d5dca67.b32764","name":"","func":"msg.payload = { \"SPjas\" : msg.payload };\nreturn msg","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1080,"y":760,"wires":[["2ca952f2.9e6f9e","8a4d82e3.8d254"]]},{"id":"3e14e8e0.4729b8","type":"yaml","z":"5d5dca67.b32764","property":"payload","name":"","x":930,"y":760,"wires":[["dd3ecf27.74337"]]},{"id":"8fd1309.6d16dd","type":"change","z":"5d5dca67.b32764","name":"set topic to wens/tempjas","rules":[{"t":"set","p":"topic","pt":"msg","to":"/wens","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":730,"y":760,"wires":[["3e14e8e0.4729b8"]]},{"id":"92e8df6f.419c","type":"function","z":"5d5dca67.b32764","name":"THB","func":"var T = msg.payload.svalue1;\nvar H = msg.payload.svalue2;\nvar B = msg.payload.svalue4;\n\nreturn[{payload:T},{payload:H},{payload:B}]","outputs":3,"noerr":0,"initialize":"","finalize":"","x":510,"y":780,"wires":[["8fd1309.6d16dd","68701b01.51ebc4"],["3fb6f6fd.fca2da"],[]]},{"id":"5fb2021b.13e87c","type":"switch","z":"5d5dca67.b32764","name":"Smart","property":"payload.idx","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"str"},{"t":"eq","v":"280","vt":"str"},{"t":"eq","v":"358","vt":"str"},{"t":"eq","v":"605","vt":"str"},{"t":"eq","v":"486","vt":"str"},{"t":"eq","v":"17","vt":"str"},{"t":"eq","v":"20","vt":"str"},{"t":"eq","v":"627","vt":"str"},{"t":"eq","v":"31","vt":"str"},{"t":"eq","v":"629","vt":"str"},{"t":"eq","v":"630","vt":"str"},{"t":"eq","v":"485","vt":"str"},{"t":"eq","v":"491","vt":"str"},{"t":"eq","v":"59","vt":"str"},{"t":"eq","v":"615","vt":"str"},{"t":"eq","v":"1162","vt":"str"}],"checkall":"true","repair":false,"outputs":16,"x":370,"y":880,"wires":[["92e8df6f.419c"],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]]},{"id":"28bb6bd3.c44a44","type":"mqtt in","z":"5d5dca67.b32764","name":"","topic":"domoticz/#","qos":"0","datatype":"json","broker":"68bc0885.f2d258","x":140,"y":880,"wires":[["b35a10d.7f3c6f","5fb2021b.13e87c"]]},{"id":"b35a10d.7f3c6f","type":"debug","z":"5d5dca67.b32764","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":230,"y":960,"wires":[]},{"id":"8054fcea.8694a","type":"mqtt-broker","name":"","broker":"192.168.78.60","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"68bc0885.f2d258","type":"mqtt-broker","name":"Meterkast","broker":"192.168.78.20","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]

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