Page 1 of 1

ph email alerts with home assistant and node red, a gift to @LEDG

Posted: Thu Mar 11, 2021 5:08 pm
by n27
:D :D this is a gift to our god @LEDG you know i am moving to adapt your build to hydroponics and in the future maybe aeroponics or even fogponic, and today i came up with a low/high ph email notification flow in node red.
first thing i added two input in my dashboard:



then i added an event state for the two slider and onefor the atlas ph sensor:



then i joined the 3 message together and modified the LEDG code to compare the ph value to the two sliders,


then there are two functions connected to the first output that build the email message:


then i put a delay node witch acts as a filter and allows only one message per hour so i dont get spammed and an email node with my recipient email and one created for home assistant with gmail and lesssecureapp(myaccount.google.com/u/1/lesssecureapps) option enabled and a debug node that shows the complete message to see the topic:




this is the complete flow:

if you want to import this flow here is the code:
[{"id":"925ad2c5.e66c3","type":"tab","label":"PH alert","disabled":false,"info":""},{"id":"8fbb9ee0.f80358","type":"function","z":"925ad2c5.e66c3","name":"","func":"if (msg.payload[\"sensor.atlas_ph\"] < (msg.payload[\"input_number.lowph_notification_value\"])) {\n return [msg, null];\n}\n\nelse if (msg.payload[\"sensor.atlas_ph\"] > (msg.payload[\"input_number.highph_notification_value\"])) {\n return [null, msg];\n}\n","outputs":2,"noerr":0,"initialize":"","finalize":"","x":700,"y":60,"wires":[["ba2ea92f.9d4648"],["4757d640.063e7"]]},{"id":"e62565fd.145ab8","type":"server-state-changed","z":"925ad2c5.e66c3","name":"","server":"76f5c2a.afb0a3c","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"sensor.atlas_ph","entityidfiltertype":"exact","outputinitially":false,"state_type":"num","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"x":170,"y":200,"wires":[["9536f9b2.7c3f6"]]},{"id":"ba2ea92f.9d4648","type":"function","z":"925ad2c5.e66c3","name":"Low Ph Msg","func":"msg = {\n payload : \"Low Ph Detected! at \" + Date().toString() + \", Ph is: \" + msg.payload[\"sensor.atlas_ph\"],\n topic : \"Low Ph Detected!!\"\n};\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":870,"y":60,"wires":[["d4e466d0.43914"]]},{"id":"97ae5987.3bc2b8","type":"e-mail","z":"925ad2c5.e66c3","server":"","port":"465","secure":true,"tls":true,"name":"","dname":"","x":1070,"y":100,"wires":[]},{"id":"3720c6f0.40ac42","type":"debug","z":"925ad2c5.e66c3","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1110,"y":220,"wires":[]},{"id":"d191ed94.7baad8","type":"server-state-changed","z":"925ad2c5.e66c3","name":"","server":"76f5c2a.afb0a3c","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"input_number.lowph_notification_value","entityidfiltertype":"exact","outputinitially":true,"state_type":"num","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"x":240,"y":60,"wires":[["9536f9b2.7c3f6"]]},{"id":"c4773008.cd5e78","type":"server-state-changed","z":"925ad2c5.e66c3","name":"","server":"76f5c2a.afb0a3c","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"input_number.highph_notification_value","entityidfiltertype":"exact","outputinitially":true,"state_type":"num","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"x":270,"y":140,"wires":[["9536f9b2.7c3f6"]]},{"id":"9536f9b2.7c3f6","type":"join","z":"925ad2c5.e66c3","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":true,"timeout":"","count":"3","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":560,"y":60,"wires":[["8fbb9ee0.f80358"]]},{"id":"4757d640.063e7","type":"function","z":"925ad2c5.e66c3","name":"High Ph Msg","func":"msg = {\n payload : \"High Ph Detected! at \" + Date().toString() + \", Ph is: \" + msg.payload[\"sensor.atlas_ph\"],\n topic : \"High Ph Detected!!\"\n};\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":868,"y":109,"wires":[["d4e466d0.43914"]]},{"id":"d4e466d0.43914","type":"delay","z":"925ad2c5.e66c3","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"hour","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":970,"y":180,"wires":[["3720c6f0.40ac42","97ae5987.3bc2b8"]]},{"id":"76f5c2a.afb0a3c","type":"server","name":"Home Assistant","addon":true}]

Re: ph email alerts with home assistant and node red, a gift to @LEDG

Posted: Thu Mar 11, 2021 8:24 pm
by LEDG
Nicely done.

I do my notifications through the app so they push to my phone. I've set a couple up in the past for high temperature, water detection, etc.

Its super easy to do through the home assistant automation editor - the trigger gets set as a numeric state, you put your "above" or "below" value on whatever entity you want to trigger the automation, then for actions, you use "Call service" and the service is notify.mobile_app[your_phone_entity].

Re: ph email alerts with home assistant and node red, a gift to @LEDG

Posted: Fri Mar 12, 2021 8:20 am
by n27
@LEDG :D :D yeah i know that there is a notification in automations but i thought you wanted to move everything from the arduinos to node red and this too XD oh well now we have two way to do that :D :D

Re: ph email alerts with home assistant and node red, a gift to @LEDG

Posted: Sat Mar 27, 2021 10:13 pm
by Morbidbystander
I just got my notification to work through node red thanks to some online help. Change node to the message you want then call service.

Change Node

set message payload

to string "What you want the notification to say."

Call Service

Domain: notify

Service: mobile_app_"id"

Leave entity id blank!

Data: { "message" : "{{payload}}" }

Works great but I want to get talk to text to speak the payload.