Compensated readings with Atlas EZO + Tasmota + Node Red

Home Assistant automation projects, questions, etc. go here.
Baalial
LED-Curious
LED-Curious
Reactions:
Posts: 5
Joined: Mon May 03, 2021 4:42 pm

Hello everyone,

I'm using Atlas Scientific Hydroponic kit, previously I wrote my own Arduino code, because with ESPhome there's no way to do calibrations, but here I learned about Tasmota so I tried it and it worked flawlessly (not needing the serial for calibration) BUT there's the compensated reading issue. Considering I'm using a chiller I thought that the variation wasn't that big. I was wrong. The water temperature range is 1.4°C, and in this range the reading drifts more than 200µS, with very unconsistent readings, so I had to find a solution, and at the end I did. I learned a lot here and now it's time to share something, so here there's the flow.
I'm using the Hydroponic kit from Atlas, but actually it could work fine with any temperature sensor and with just the pH or EC EZO.

Code: Select all

[{"id":"ab12abbd.da61f8","type":"tab","label":"Flow 2","disabled":false,"info":""},{"id":"9b01bcd.554e24","type":"inject","z":"ab12abbd.da61f8","name":"RT EC","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"6","crontab":"","once":true,"onceDelay":"0.1","topic":"cmnd/tasmota_atlas/Sensor78","payload":"-2 RT,","payloadType":"str","x":360,"y":260,"wires":[["cd981553.958df8","7c7c6289.dce7fc","a979de5.c24232"]]},{"id":"6d99af9f.0903c","type":"mqtt out","z":"ab12abbd.da61f8","name":"","topic":"","qos":"1","retain":"","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"57ba50fe.6e951","x":970,"y":280,"wires":[]},{"id":"cd981553.958df8","type":"function","z":"ab12abbd.da61f8","name":"","func":"var watertemp = global.get(\"global_watertemp\");\nwatertemp.toString();\nmsg.payload += watertemp;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":600,"y":280,"wires":[["848defde.0f32d"]]},{"id":"83834a47.81be28","type":"mqtt in","z":"ab12abbd.da61f8","name":"","topic":"stat/tasmota_atlas/RESULT","qos":"2","datatype":"auto","broker":"57ba50fe.6e951","nl":false,"rap":true,"rh":0,"x":1480,"y":280,"wires":[["a15ac89.1393b38"]]},{"id":"a15ac89.1393b38","type":"function","z":"ab12abbd.da61f8","name":"Purge message","func":"msg.payload = msg.payload.substring(11, msg.payload.length - 2)\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1740,"y":280,"wires":[["eb598572.93f448","efd2eb92.cc5768"]]},{"id":"9fb3622c.abccf","type":"ha-entity","z":"ab12abbd.da61f8","name":"EC Comp","server":"da5e77a8.b1b498","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"EC Comp"},{"property":"device_class","value":""},{"property":"icon","value":"mdi:beaker-outline"},{"property":"unit_of_measurement","value":"µS"}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":2140,"y":240,"wires":[[]]},{"id":"cdd568b1.1a0458","type":"ha-entity","z":"ab12abbd.da61f8","name":"pH Comp","server":"da5e77a8.b1b498","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"pH Comp"},{"property":"device_class","value":""},{"property":"icon","value":"mdi:eyedropper"},{"property":"unit_of_measurement","value":"pH"}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":2140,"y":320,"wires":[[]]},{"id":"eb598572.93f448","type":"switch","z":"ab12abbd.da61f8","name":"ECrecON ?","property":"ECrecON","propertyType":"flow","rules":[{"t":"eq","v":"1","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":1950,"y":240,"wires":[["9fb3622c.abccf"]]},{"id":"efd2eb92.cc5768","type":"switch","z":"ab12abbd.da61f8","name":"pHrecON ?","property":"pHrecON","propertyType":"flow","rules":[{"t":"eq","v":"1","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":1950,"y":320,"wires":[["cdd568b1.1a0458"]]},{"id":"c3cf258e.c4c2f8","type":"inject","z":"ab12abbd.da61f8","name":"RT pH","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"6","crontab":"","once":true,"onceDelay":"3. 1","topic":"cmnd/tasmota_atlas/Sensor78","payload":"-1 RT,","payloadType":"str","x":360,"y":300,"wires":[["cd981553.958df8","7c7c6289.dce7fc","519487bf.cbd088"]]},{"id":"3ecea826.681158","type":"trigger","z":"ab12abbd.da61f8","name":"","op1":"1","op2":"0","op1type":"str","op2type":"str","duration":"2","extend":false,"overrideDelay":false,"units":"s","reset":"reset","bytopic":"all","topic":"topic","outputs":1,"x":980,"y":180,"wires":[["2827ec99.159f44"]]},{"id":"2827ec99.159f44","type":"change","z":"ab12abbd.da61f8","name":"","rules":[{"t":"set","p":"ECrecON","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1170,"y":180,"wires":[[]]},{"id":"7d2b262c.1406d8","type":"trigger","z":"ab12abbd.da61f8","name":"","op1":"1","op2":"0","op1type":"str","op2type":"str","duration":"2","extend":false,"overrideDelay":false,"units":"s","reset":"reset","bytopic":"all","topic":"topic","outputs":1,"x":980,"y":360,"wires":[["3e69f4d7.8bbffc"]]},{"id":"3e69f4d7.8bbffc","type":"change","z":"ab12abbd.da61f8","name":"","rules":[{"t":"set","p":"pHrecON","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1190,"y":360,"wires":[[]]},{"id":"2ee894dc.25e67c","type":"comment","z":"ab12abbd.da61f8","name":"Compensation","info":"","x":130,"y":280,"wires":[]},{"id":"1638580e.5c2838","type":"change","z":"ab12abbd.da61f8","name":"","rules":[{"t":"set","p":"pollingON","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":950,"y":460,"wires":[[]]},{"id":"7c7c6289.dce7fc","type":"api-current-state","z":"ab12abbd.da61f8","name":"","server":"da5e77a8.b1b498","version":1,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"input_boolean.polling","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":680,"y":460,"wires":[["1638580e.5c2838"]]},{"id":"848defde.0f32d","type":"switch","z":"ab12abbd.da61f8","name":"pollingON ?","property":"pollingON","propertyType":"flow","rules":[{"t":"eq","v":"on","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":790,"y":280,"wires":[["6d99af9f.0903c"]]},{"id":"a979de5.c24232","type":"switch","z":"ab12abbd.da61f8","name":"pollingON ?","property":"pollingON","propertyType":"flow","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":610,"y":180,"wires":[["3ecea826.681158"],["321a4ad3.00dfe6"]]},{"id":"519487bf.cbd088","type":"switch","z":"ab12abbd.da61f8","name":"pollingON ?","property":"pollingON","propertyType":"flow","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":610,"y":360,"wires":[["7d2b262c.1406d8"],["8dddd3dd.18812"]]},{"id":"321a4ad3.00dfe6","type":"change","z":"ab12abbd.da61f8","name":"","rules":[{"t":"set","p":"reset","pt":"msg","to":"1","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":800,"y":220,"wires":[["3ecea826.681158"]]},{"id":"8dddd3dd.18812","type":"change","z":"ab12abbd.da61f8","name":"","rules":[{"t":"set","p":"reset","pt":"msg","to":"1","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":800,"y":400,"wires":[["7d2b262c.1406d8"]]},{"id":"57ba50fe.6e951","type":"mqtt-broker","name":"MQTT_Broker","broker":"192.168.16.76","port":"1883","clientid":"","usetls":false,"protocolVersion":4,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"da5e77a8.b1b498","type":"server","name":"Home Assistant","legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]
I'm not a code writer and I learned by myself, so probably it can be improved, but it works.

What I do is to continuosly and asynchronally ask to the Tasmota the compensated readings (pH and EC) using the temp reading coming from the Tasmota telemetry (the command is RT,temperature and the function add the temperature to the request). The problem is that the answer is always something like "{"Sensor":"5.753"}" or "{"Sensor":"1423.0"}" and always in the same topic. So first there's a function that purges the payload, and then what I did to split the messages to pH and EC is to create 2 variables and trigger each one for 2 seconds when the request is sent, double checking and blocking the wrong reading in the mqtt in, and then store the values in 2 virtual entities. The polling entity is created to temporary stop the requests during calibrations.

I hope it can be helpful for someone.
stud
LED Lover
LED Lover
Reactions:
Posts: 143
Joined: Wed Jun 03, 2020 4:19 pm
Location: Canada

:geek: :geek: :geek: :mrgreen: :mrgreen: :mrgreen: i'm about to try/learn Node-Red soon , didnt get into it yet ,i'm loving HA for the last 4 years so NodeRed is a must , thx for sharing and welcome to the community
Elburro24
LED-Curious
LED-Curious
Reactions:
Posts: 17
Joined: Tue Feb 23, 2021 9:43 am

Thanks for sharing. I just got my barebones wifi kit in from atlas scientific and was just about to order in just the ec probe for it but it sounds like I should just pull the trigger on temp as well. I wasn't expecting such a wide swing in ppm based on the temp. I'm sure ill have some questions for you when I get it all in, hope you don't mind me bothering you in a week or two 🙂
Baalial wrote:
Mon May 03, 2021 5:37 pm
Hello everyone,

I'm using Atlas Scientific Hydroponic kit, previously I wrote my own Arduino code, because with ESPhome there's no way to do calibrations, but here I learned about Tasmota so I tried it and it worked flawlessly (not needing the serial for calibration) BUT there's the compensated reading issue. Considering I'm using a chiller I thought that the variation wasn't that big. I was wrong. The water temperature range is 1.4°C, and in this range the reading drifts more than 200µS, with very unconsistent readings, so I had to find a solution, and at the end I did. I learned a lot here and now it's time to share something, so here there's the flow.
I'm using the Hydroponic kit from Atlas, but actually it could work fine with any temperature sensor and with just the pH or EC EZO.

Code: Select all

[{"id":"ab12abbd.da61f8","type":"tab","label":"Flow 2","disabled":false,"info":""},{"id":"9b01bcd.554e24","type":"inject","z":"ab12abbd.da61f8","name":"RT EC","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"6","crontab":"","once":true,"onceDelay":"0.1","topic":"cmnd/tasmota_atlas/Sensor78","payload":"-2 RT,","payloadType":"str","x":360,"y":260,"wires":[["cd981553.958df8","7c7c6289.dce7fc","a979de5.c24232"]]},{"id":"6d99af9f.0903c","type":"mqtt out","z":"ab12abbd.da61f8","name":"","topic":"","qos":"1","retain":"","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"57ba50fe.6e951","x":970,"y":280,"wires":[]},{"id":"cd981553.958df8","type":"function","z":"ab12abbd.da61f8","name":"","func":"var watertemp = global.get(\"global_watertemp\");\nwatertemp.toString();\nmsg.payload += watertemp;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":600,"y":280,"wires":[["848defde.0f32d"]]},{"id":"83834a47.81be28","type":"mqtt in","z":"ab12abbd.da61f8","name":"","topic":"stat/tasmota_atlas/RESULT","qos":"2","datatype":"auto","broker":"57ba50fe.6e951","nl":false,"rap":true,"rh":0,"x":1480,"y":280,"wires":[["a15ac89.1393b38"]]},{"id":"a15ac89.1393b38","type":"function","z":"ab12abbd.da61f8","name":"Purge message","func":"msg.payload = msg.payload.substring(11, msg.payload.length - 2)\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1740,"y":280,"wires":[["eb598572.93f448","efd2eb92.cc5768"]]},{"id":"9fb3622c.abccf","type":"ha-entity","z":"ab12abbd.da61f8","name":"EC Comp","server":"da5e77a8.b1b498","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"EC Comp"},{"property":"device_class","value":""},{"property":"icon","value":"mdi:beaker-outline"},{"property":"unit_of_measurement","value":"µS"}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":2140,"y":240,"wires":[[]]},{"id":"cdd568b1.1a0458","type":"ha-entity","z":"ab12abbd.da61f8","name":"pH Comp","server":"da5e77a8.b1b498","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"pH Comp"},{"property":"device_class","value":""},{"property":"icon","value":"mdi:eyedropper"},{"property":"unit_of_measurement","value":"pH"}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":2140,"y":320,"wires":[[]]},{"id":"eb598572.93f448","type":"switch","z":"ab12abbd.da61f8","name":"ECrecON ?","property":"ECrecON","propertyType":"flow","rules":[{"t":"eq","v":"1","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":1950,"y":240,"wires":[["9fb3622c.abccf"]]},{"id":"efd2eb92.cc5768","type":"switch","z":"ab12abbd.da61f8","name":"pHrecON ?","property":"pHrecON","propertyType":"flow","rules":[{"t":"eq","v":"1","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":1950,"y":320,"wires":[["cdd568b1.1a0458"]]},{"id":"c3cf258e.c4c2f8","type":"inject","z":"ab12abbd.da61f8","name":"RT pH","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"6","crontab":"","once":true,"onceDelay":"3. 1","topic":"cmnd/tasmota_atlas/Sensor78","payload":"-1 RT,","payloadType":"str","x":360,"y":300,"wires":[["cd981553.958df8","7c7c6289.dce7fc","519487bf.cbd088"]]},{"id":"3ecea826.681158","type":"trigger","z":"ab12abbd.da61f8","name":"","op1":"1","op2":"0","op1type":"str","op2type":"str","duration":"2","extend":false,"overrideDelay":false,"units":"s","reset":"reset","bytopic":"all","topic":"topic","outputs":1,"x":980,"y":180,"wires":[["2827ec99.159f44"]]},{"id":"2827ec99.159f44","type":"change","z":"ab12abbd.da61f8","name":"","rules":[{"t":"set","p":"ECrecON","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1170,"y":180,"wires":[[]]},{"id":"7d2b262c.1406d8","type":"trigger","z":"ab12abbd.da61f8","name":"","op1":"1","op2":"0","op1type":"str","op2type":"str","duration":"2","extend":false,"overrideDelay":false,"units":"s","reset":"reset","bytopic":"all","topic":"topic","outputs":1,"x":980,"y":360,"wires":[["3e69f4d7.8bbffc"]]},{"id":"3e69f4d7.8bbffc","type":"change","z":"ab12abbd.da61f8","name":"","rules":[{"t":"set","p":"pHrecON","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1190,"y":360,"wires":[[]]},{"id":"2ee894dc.25e67c","type":"comment","z":"ab12abbd.da61f8","name":"Compensation","info":"","x":130,"y":280,"wires":[]},{"id":"1638580e.5c2838","type":"change","z":"ab12abbd.da61f8","name":"","rules":[{"t":"set","p":"pollingON","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":950,"y":460,"wires":[[]]},{"id":"7c7c6289.dce7fc","type":"api-current-state","z":"ab12abbd.da61f8","name":"","server":"da5e77a8.b1b498","version":1,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"input_boolean.polling","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":680,"y":460,"wires":[["1638580e.5c2838"]]},{"id":"848defde.0f32d","type":"switch","z":"ab12abbd.da61f8","name":"pollingON ?","property":"pollingON","propertyType":"flow","rules":[{"t":"eq","v":"on","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":790,"y":280,"wires":[["6d99af9f.0903c"]]},{"id":"a979de5.c24232","type":"switch","z":"ab12abbd.da61f8","name":"pollingON ?","property":"pollingON","propertyType":"flow","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":610,"y":180,"wires":[["3ecea826.681158"],["321a4ad3.00dfe6"]]},{"id":"519487bf.cbd088","type":"switch","z":"ab12abbd.da61f8","name":"pollingON ?","property":"pollingON","propertyType":"flow","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":610,"y":360,"wires":[["7d2b262c.1406d8"],["8dddd3dd.18812"]]},{"id":"321a4ad3.00dfe6","type":"change","z":"ab12abbd.da61f8","name":"","rules":[{"t":"set","p":"reset","pt":"msg","to":"1","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":800,"y":220,"wires":[["3ecea826.681158"]]},{"id":"8dddd3dd.18812","type":"change","z":"ab12abbd.da61f8","name":"","rules":[{"t":"set","p":"reset","pt":"msg","to":"1","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":800,"y":400,"wires":[["7d2b262c.1406d8"]]},{"id":"57ba50fe.6e951","type":"mqtt-broker","name":"MQTT_Broker","broker":"192.168.16.76","port":"1883","clientid":"","usetls":false,"protocolVersion":4,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"da5e77a8.b1b498","type":"server","name":"Home Assistant","legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]
I'm not a code writer and I learned by myself, so probably it can be improved, but it works.

What I do is to continuosly and asynchronally ask to the Tasmota the compensated readings (pH and EC) using the temp reading coming from the Tasmota telemetry (the command is RT,temperature and the function add the temperature to the request). The problem is that the answer is always something like "{"Sensor":"5.753"}" or "{"Sensor":"1423.0"}" and always in the same topic. So first there's a function that purges the payload, and then what I did to split the messages to pH and EC is to create 2 variables and trigger each one for 2 seconds when the request is sent, double checking and blocking the wrong reading in the mqtt in, and then store the values in 2 virtual entities. The polling entity is created to temporary stop the requests during calibrations.

I hope it can be helpful for someone.
stevewull
LED-Curious
LED-Curious
Reactions:
Posts: 4
Joined: Mon Apr 26, 2021 12:09 am

Thanks for sharing. One thing I do on an hourly basis within a Node-red routine is read the temperature from the PT-1000 probe, then issue the temperature compensation command to the pH and EC probes: "T,temperature". Temperature compensation value is stored until the probe controller is turned off. It reverts to 25c on startup.
p0intman
LED-Curious
LED-Curious
Reactions:
Posts: 4
Joined: Mon Apr 05, 2021 2:17 am

Baalial wrote:
Mon May 03, 2021 5:37 pm
Hello everyone,

I'm using Atlas Scientific Hydroponic kit, previously I wrote my own Arduino code, because with ESPhome there's no way to do calibrations, but here I learned about Tasmota so I tried it and it worked flawlessly (not needing the serial for calibration) BUT there's the compensated reading issue. Considering I'm using a chiller I thought that the variation wasn't that big. I was wrong. The water temperature range is 1.4°C, and in this range the reading drifts more than 200µS, with very unconsistent readings, so I had to find a solution, and at the end I did. I learned a lot here and now it's time to share something, so here there's the flow.
I'm using the Hydroponic kit from Atlas, but actually it could work fine with any temperature sensor and with just the pH or EC EZO.

Code: Select all

[{"id":"ab12abbd.da61f8","type":"tab","label":"Flow 2","disabled":false,"info":""},{"id":"9b01bcd.554e24","type":"inject","z":"ab12abbd.da61f8","name":"RT EC","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"6","crontab":"","once":true,"onceDelay":"0.1","topic":"cmnd/tasmota_atlas/Sensor78","payload":"-2 RT,","payloadType":"str","x":360,"y":260,"wires":[["cd981553.958df8","7c7c6289.dce7fc","a979de5.c24232"]]},{"id":"6d99af9f.0903c","type":"mqtt out","z":"ab12abbd.da61f8","name":"","topic":"","qos":"1","retain":"","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"57ba50fe.6e951","x":970,"y":280,"wires":[]},{"id":"cd981553.958df8","type":"function","z":"ab12abbd.da61f8","name":"","func":"var watertemp = global.get(\"global_watertemp\");\nwatertemp.toString();\nmsg.payload += watertemp;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":600,"y":280,"wires":[["848defde.0f32d"]]},{"id":"83834a47.81be28","type":"mqtt in","z":"ab12abbd.da61f8","name":"","topic":"stat/tasmota_atlas/RESULT","qos":"2","datatype":"auto","broker":"57ba50fe.6e951","nl":false,"rap":true,"rh":0,"x":1480,"y":280,"wires":[["a15ac89.1393b38"]]},{"id":"a15ac89.1393b38","type":"function","z":"ab12abbd.da61f8","name":"Purge message","func":"msg.payload = msg.payload.substring(11, msg.payload.length - 2)\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1740,"y":280,"wires":[["eb598572.93f448","efd2eb92.cc5768"]]},{"id":"9fb3622c.abccf","type":"ha-entity","z":"ab12abbd.da61f8","name":"EC Comp","server":"da5e77a8.b1b498","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"EC Comp"},{"property":"device_class","value":""},{"property":"icon","value":"mdi:beaker-outline"},{"property":"unit_of_measurement","value":"µS"}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":2140,"y":240,"wires":[[]]},{"id":"cdd568b1.1a0458","type":"ha-entity","z":"ab12abbd.da61f8","name":"pH Comp","server":"da5e77a8.b1b498","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"pH Comp"},{"property":"device_class","value":""},{"property":"icon","value":"mdi:eyedropper"},{"property":"unit_of_measurement","value":"pH"}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":2140,"y":320,"wires":[[]]},{"id":"eb598572.93f448","type":"switch","z":"ab12abbd.da61f8","name":"ECrecON ?","property":"ECrecON","propertyType":"flow","rules":[{"t":"eq","v":"1","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":1950,"y":240,"wires":[["9fb3622c.abccf"]]},{"id":"efd2eb92.cc5768","type":"switch","z":"ab12abbd.da61f8","name":"pHrecON ?","property":"pHrecON","propertyType":"flow","rules":[{"t":"eq","v":"1","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":1950,"y":320,"wires":[["cdd568b1.1a0458"]]},{"id":"c3cf258e.c4c2f8","type":"inject","z":"ab12abbd.da61f8","name":"RT pH","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"6","crontab":"","once":true,"onceDelay":"3. 1","topic":"cmnd/tasmota_atlas/Sensor78","payload":"-1 RT,","payloadType":"str","x":360,"y":300,"wires":[["cd981553.958df8","7c7c6289.dce7fc","519487bf.cbd088"]]},{"id":"3ecea826.681158","type":"trigger","z":"ab12abbd.da61f8","name":"","op1":"1","op2":"0","op1type":"str","op2type":"str","duration":"2","extend":false,"overrideDelay":false,"units":"s","reset":"reset","bytopic":"all","topic":"topic","outputs":1,"x":980,"y":180,"wires":[["2827ec99.159f44"]]},{"id":"2827ec99.159f44","type":"change","z":"ab12abbd.da61f8","name":"","rules":[{"t":"set","p":"ECrecON","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1170,"y":180,"wires":[[]]},{"id":"7d2b262c.1406d8","type":"trigger","z":"ab12abbd.da61f8","name":"","op1":"1","op2":"0","op1type":"str","op2type":"str","duration":"2","extend":false,"overrideDelay":false,"units":"s","reset":"reset","bytopic":"all","topic":"topic","outputs":1,"x":980,"y":360,"wires":[["3e69f4d7.8bbffc"]]},{"id":"3e69f4d7.8bbffc","type":"change","z":"ab12abbd.da61f8","name":"","rules":[{"t":"set","p":"pHrecON","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1190,"y":360,"wires":[[]]},{"id":"2ee894dc.25e67c","type":"comment","z":"ab12abbd.da61f8","name":"Compensation","info":"","x":130,"y":280,"wires":[]},{"id":"1638580e.5c2838","type":"change","z":"ab12abbd.da61f8","name":"","rules":[{"t":"set","p":"pollingON","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":950,"y":460,"wires":[[]]},{"id":"7c7c6289.dce7fc","type":"api-current-state","z":"ab12abbd.da61f8","name":"","server":"da5e77a8.b1b498","version":1,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"input_boolean.polling","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":680,"y":460,"wires":[["1638580e.5c2838"]]},{"id":"848defde.0f32d","type":"switch","z":"ab12abbd.da61f8","name":"pollingON ?","property":"pollingON","propertyType":"flow","rules":[{"t":"eq","v":"on","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":790,"y":280,"wires":[["6d99af9f.0903c"]]},{"id":"a979de5.c24232","type":"switch","z":"ab12abbd.da61f8","name":"pollingON ?","property":"pollingON","propertyType":"flow","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":610,"y":180,"wires":[["3ecea826.681158"],["321a4ad3.00dfe6"]]},{"id":"519487bf.cbd088","type":"switch","z":"ab12abbd.da61f8","name":"pollingON ?","property":"pollingON","propertyType":"flow","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":610,"y":360,"wires":[["7d2b262c.1406d8"],["8dddd3dd.18812"]]},{"id":"321a4ad3.00dfe6","type":"change","z":"ab12abbd.da61f8","name":"","rules":[{"t":"set","p":"reset","pt":"msg","to":"1","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":800,"y":220,"wires":[["3ecea826.681158"]]},{"id":"8dddd3dd.18812","type":"change","z":"ab12abbd.da61f8","name":"","rules":[{"t":"set","p":"reset","pt":"msg","to":"1","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":800,"y":400,"wires":[["7d2b262c.1406d8"]]},{"id":"57ba50fe.6e951","type":"mqtt-broker","name":"MQTT_Broker","broker":"192.168.16.76","port":"1883","clientid":"","usetls":false,"protocolVersion":4,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"da5e77a8.b1b498","type":"server","name":"Home Assistant","legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]
I'm not a code writer and I learned by myself, so probably it can be improved, but it works.

What I do is to continuosly and asynchronally ask to the Tasmota the compensated readings (pH and EC) using the temp reading coming from the Tasmota telemetry (the command is RT,temperature and the function add the temperature to the request). The problem is that the answer is always something like "{"Sensor":"5.753"}" or "{"Sensor":"1423.0"}" and always in the same topic. So first there's a function that purges the payload, and then what I did to split the messages to pH and EC is to create 2 variables and trigger each one for 2 seconds when the request is sent, double checking and blocking the wrong reading in the mqtt in, and then store the values in 2 virtual entities. The polling entity is created to temporary stop the requests during calibrations.

I hope it can be helpful for someone.
Thanks for sharing I was trying to get this working and was wondering where you are getting the following global variable global_watertemp from in your function
'var watertemp = global.get("global_watertemp");'
morrisraybrooks
LED Enthusiast
LED Enthusiast
Reactions:
Posts: 57
Joined: Fri Dec 04, 2020 3:27 am

thanks for sharing this trying to get this working as well no luck yet kinda lost here
warmachine
LED-Curious
LED-Curious
Reactions:
Posts: 18
Joined: Wed Sep 02, 2020 3:48 am

stevewull wrote:
Fri May 21, 2021 7:21 am
Thanks for sharing. One thing I do on an hourly basis within a Node-red routine is read the temperature from the PT-1000 probe, then issue the temperature compensation command to the pH and EC probes: "T,temperature". Temperature compensation value is stored until the probe controller is turned off. It reverts to 25c on startup.
Could you share the string you use? I haven't tried nodered with ezos yet and I need to.
morrisraybrooks
LED Enthusiast
LED Enthusiast
Reactions:
Posts: 57
Joined: Fri Dec 04, 2020 3:27 am

function : (error)
"TypeError: Cannot read property 'toString' of undefined"


what does this mean
help
p0intman
LED-Curious
LED-Curious
Reactions:
Posts: 4
Joined: Mon Apr 05, 2021 2:17 am

I have been working on this problem and this is the best the following flow is what I came up with so far. I subscribe to the Tasmota topic strip the temperature and put a 'only if change block' in front of the commands to t run the compensation only when the temperature changes I do have the following pallets installed to make this work as I needed the temp in Celsius node-red-contrib-tasmota hope it helps.

Code: Select all

[{"id":"eb2dae29.c183","type":"Tasmota Sensor","z":"ea3f1d68.9198c","broker":"","device":"tasmota_atlas","name":"tasmota_atlas","outputs":1,"uidisabler":false,"fullTopic":"","cmndPrefix":"","statPrefix":"","telePrefix":"","qos":1,"retain":false,"rules":[],"outputTopic":"","x":120,"y":100,"wires":[["ccb3fada.655c98"]]},{"id":"ccb3fada.655c98","type":"function","z":"ea3f1d68.9198c","name":"Strip Temp","func":"var newMsg = { payload: msg.payload[\"EZO-3\"].Temperature };\nreturn newMsg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":270,"y":160,"wires":[["587f1c26.673df4"]]},{"id":"f7d2aba0.a206a8","type":"mqtt out","z":"ea3f1d68.9198c","name":"Sensor78 topic","topic":"cmnd/tasmota_atlas/Sensor78","qos":"","retain":"","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"fef1dfff.9d787","x":920,"y":160,"wires":[]},{"id":"7458809e.ff405","type":"template","z":"ea3f1d68.9198c","name":"PH Comp","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"-1 RT,{{payload}}","output":"str","x":580,"y":120,"wires":[["9ca047e.e72fcb8"]]},{"id":"436ae382.7da7dc","type":"template","z":"ea3f1d68.9198c","name":"EC Comp","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"-2 RT,{{payload}}","output":"str","x":580,"y":180,"wires":[["9ca047e.e72fcb8"]]},{"id":"9ca047e.e72fcb8","type":"delay","z":"ea3f1d68.9198c","name":"limit","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"10","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":730,"y":160,"wires":[["f7d2aba0.a206a8"]]},{"id":"587f1c26.673df4","type":"rbe","z":"ea3f1d68.9198c","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":true,"property":"payload","x":430,"y":160,"wires":[["7458809e.ff405","436ae382.7da7dc"]]},{"id":"fef1dfff.9d787","type":"mqtt-broker","name":"mqtt","broker":"192.168.1.25","port":"1883","clientid":"","usetls":false,"protocolVersion":"4","keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"sessionExpiry":""}]
morrisraybrooks
LED Enthusiast
LED Enthusiast
Reactions:
Posts: 57
Joined: Fri Dec 04, 2020 3:27 am

finally got it working had to mod it a little

Code: Select all

[{"id":"e56ae28c.79662","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"ab4d502.11869b","type":"template","z":"e56ae28c.79662","name":"PH Comp","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"-1 RT,{{payload}}","output":"str","x":420,"y":200,"wires":[["8004fa24.c2e62"]]},{"id":"cb00f58.e2a9508","type":"template","z":"e56ae28c.79662","name":"EC Comp","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"-2 RT,{{payload}}","output":"str","x":420,"y":240,"wires":[["8004fa24.c2e62"]]},{"id":"8004fa24.c2e62","type":"delay","z":"e56ae28c.79662","name":"limit","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"10","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":590,"y":200,"wires":[["6cfd26.557022dc","b71ee6e6.66f1a"]]},{"id":"c4e2e926.d5be18","type":"rbe","z":"e56ae28c.79662","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":true,"property":"payload","x":210,"y":240,"wires":[["ab4d502.11869b","cb00f58.e2a9508"]]},{"id":"1728eb4b.fe1bb5","type":"poll-state","z":"e56ae28c.79662","name":"Garden_Hydro_kit_1","server":"","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"updateinterval":"5","updateIntervalUnits":"seconds","outputinitially":true,"outputonchanged":true,"entity_id":"sensor.garden_hydro_kit_1_ezo_3_temperature","state_type":"str","halt_if":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"x":170,"y":100,"wires":[["44835c03.3a0004"]]},{"id":"6cfd26.557022dc","type":"mqtt out","z":"e56ae28c.79662","name":"Garden_Hydro_kit_1_Sensor78_topic","topic":"cmnd/Garden_Hydro_kit_1/Sensor78","qos":"","retain":"","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"22146a63.8b87f6","x":550,"y":100,"wires":[]},{"id":"44835c03.3a0004","type":"unit-converter","z":"e56ae28c.79662","category":"temperature","inputUnit":"F","outputUnit":"C","inputField":"payload","outputField":"payload","inputFieldType":"msg","outputFieldType":"msg","roundOutputField":true,"outputFieldDecimals":"0","name":"kit_1_ezo_3_temperature","x":190,"y":160,"wires":[["c4e2e926.d5be18"]]},{"id":"b71ee6e6.66f1a","type":"debug","z":"e56ae28c.79662","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":630,"y":260,"wires":[]},{"id":"22146a63.8b87f6","type":"mqtt-broker","name":"home assistant","broker":"192.168.0.192","port":"1883","clientid":"","usetls":false,"protocolVersion":"4","keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"sessionExpiry":""}]
Post Reply