Time Check From 2 csv files

easy fix for this
in CSV node instead of leaving the Columns field empty .. which will default to col1, col2, col3 ..
add the names of the Columns .. comma seperated

image

1 Like

changed that ty

{"warn":"6.6","high":"6.3","low":"5.4","dose":"5.2","log":{"time":"2022-01-30 09:15:00","%":"ppm500","F":"F","Ppm":1630,"Ph":5.9,"Temp":71}}
[{"id":"c70d5be49b4d2a61","type":"tab","label":"Flow 1","disabled":false,"info":"","env":[]},{"id":"ae7cf6a489b7ad36","type":"file in","z":"c70d5be49b4d2a61","name":"read","filename":"/config/grogreen.csv","format":"lines","chunk":false,"sendError":false,"encoding":"none","allProps":false,"x":1830,"y":620,"wires":[["32d8ddc9f7e7179e"]]},{"id":"2f2ed224c4744c97","type":"function","z":"c70d5be49b4d2a61","name":"last line","func":"let lines = msg.payload\nmsg.payload = lines[lines.length - 2]\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":2200,"y":620,"wires":[["07285056079b915d"]]},{"id":"fb2fc7b6be6fd7a4","type":"join","z":"c70d5be49b4d2a61","name":"","mode":"custom","build":"array","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":2070,"y":620,"wires":[["2f2ed224c4744c97"]]},{"id":"32d8ddc9f7e7179e","type":"csv","z":"c70d5be49b4d2a61","name":"","sep":",","hdrin":"","hdrout":"none","multi":"one","ret":"\\n","temp":"","skip":"0","strings":true,"include_empty_strings":"","include_null_values":"","x":1950,"y":620,"wires":[["fb2fc7b6be6fd7a4"]]},{"id":"ac71b1021741bdaf","type":"api-current-state","z":"c70d5be49b4d2a61","name":"dose","server":"a52fadfc.d75d","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"input_number.ph_dose","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"},{"property":"topic","propertyType":"msg","value":"dose","valueType":"str"}],"for":0,"forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":2330,"y":380,"wires":[["cffd6e459ae1e3f4"]]},{"id":"6f2d57c0407125a7","type":"api-current-state","z":"c70d5be49b4d2a61","name":"low","server":"a52fadfc.d75d","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"input_number.ph_low","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"},{"property":"topic","propertyType":"msg","value":"low","valueType":"str"}],"for":0,"forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":2330,"y":440,"wires":[["cffd6e459ae1e3f4"]]},{"id":"6f2f31264ee251da","type":"api-current-state","z":"c70d5be49b4d2a61","name":"high","server":"a52fadfc.d75d","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"input_number.ph_high","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"},{"property":"topic","propertyType":"msg","value":"high","valueType":"str"}],"for":0,"forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":2330,"y":500,"wires":[["cffd6e459ae1e3f4"]]},{"id":"4595d91c0b6d957b","type":"api-current-state","z":"c70d5be49b4d2a61","name":"warn","server":"a52fadfc.d75d","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"input_number.ph_warn","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"},{"property":"topic","propertyType":"msg","value":"warn","valueType":"str"}],"for":0,"forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":2330,"y":560,"wires":[["cffd6e459ae1e3f4"]]},{"id":"cffd6e459ae1e3f4","type":"join","z":"c70d5be49b4d2a61","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"5","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":2490,"y":620,"wires":[["4e2edfae8f0bc7bd"]]},{"id":"4e2edfae8f0bc7bd","type":"switch","z":"c70d5be49b4d2a61","name":"","property":"payload.log.col5","propertyType":"msg","rules":[{"t":"gte","v":"payload.warn","vt":"msg"},{"t":"btwn","v":"payload.low","vt":"msg","v2":"payload.high","v2t":"msg"},{"t":"lte","v":"payload.dose","vt":"msg"}],"checkall":"false","repair":true,"outputs":3,"x":2610,"y":620,"wires":[["552ea4cb7aabe04e"],["529f5ae2ce49085e"],["6009a108c948f0b2"]]},{"id":"07285056079b915d","type":"change","z":"c70d5be49b4d2a61","name":"SMC","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.log.col5","tot":"msg"},{"t":"set","p":"topic","pt":"msg","to":"log","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":2330,"y":620,"wires":[["cffd6e459ae1e3f4"]]},{"id":"464aa6c7611abc5c","type":"inject","z":"c70d5be49b4d2a61","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"360","crontab":"","once":true,"onceDelay":0.1,"topic":"","payloadType":"date","x":490,"y":640,"wires":[["130ca3465c6bd26f","83e7f26f03c0d38a","7e5fcb5dd6ef1686"]]},{"id":"83e7f26f03c0d38a","type":"file in","z":"c70d5be49b4d2a61","name":"read","filename":"/config/grogreen.csv","format":"lines","chunk":false,"sendError":false,"encoding":"none","allProps":false,"x":630,"y":640,"wires":[["f3a37e3d36a20f63"]]},{"id":"80228cf2058f30cb","type":"function","z":"c70d5be49b4d2a61","name":"last line","func":"let lines = msg.payload\nmsg.payload = lines[lines.length - 2]\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1000,"y":640,"wires":[["a558317529cb7a1a"]]},{"id":"a72693d373bf28f1","type":"join","z":"c70d5be49b4d2a61","name":"","mode":"custom","build":"array","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":870,"y":640,"wires":[["80228cf2058f30cb"]]},{"id":"f3a37e3d36a20f63","type":"csv","z":"c70d5be49b4d2a61","name":"","sep":",","hdrin":"","hdrout":"none","multi":"one","ret":"\\n","temp":"","skip":"0","strings":true,"include_empty_strings":"","include_null_values":"","x":750,"y":640,"wires":[["a72693d373bf28f1"]]},{"id":"130ca3465c6bd26f","type":"moment","z":"c70d5be49b4d2a61","name":"","topic":"Ctime","input":"","inputType":"msg","inTz":"America/New_York","adjAmount":0,"adjType":"days","adjDir":"add","format":"YYYYMMDDHHmm","locale":"C","output":"","outputType":"msg","outTz":"America/New_York","x":1310,"y":600,"wires":[["0818f3b9029fcd7c"]]},{"id":"40d79082eff83879","type":"function","z":"c70d5be49b4d2a61","name":"payload","func":"var content1 = msg.payload[0];\nvar content2 = msg.payload[1];\n\n{\nmsg.payload = (content1 - content2)\n}\n\nreturn msg","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1580,"y":620,"wires":[["9728e7a5e3d99861"]]},{"id":"0818f3b9029fcd7c","type":"join","z":"c70d5be49b4d2a61","name":"","mode":"custom","build":"object","property":"topic","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":1450,"y":620,"wires":[["40d79082eff83879"]]},{"id":"a558317529cb7a1a","type":"change","z":"c70d5be49b4d2a61","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.col1","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1160,"y":640,"wires":[["6409cae3ba313d5e"]]},{"id":"6409cae3ba313d5e","type":"moment","z":"c70d5be49b4d2a61","name":"","topic":"ftime","input":"","inputType":"msg","inTz":"America/New_York","adjAmount":0,"adjType":"days","adjDir":"add","format":"YYYYMMDDHHmm","locale":"C","output":"","outputType":"msg","outTz":"America/New_York","x":1310,"y":640,"wires":[["0818f3b9029fcd7c"]]},{"id":"9728e7a5e3d99861","type":"switch","z":"c70d5be49b4d2a61","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"2","vt":"num"},{"t":"gte","v":"3","vt":"num"}],"checkall":"false","repair":true,"outputs":2,"x":1710,"y":620,"wires":[["ae7cf6a489b7ad36","4595d91c0b6d957b","6f2f31264ee251da","6f2d57c0407125a7","ac71b1021741bdaf"],["459669f03e08c4a6"]]},{"id":"552ea4cb7aabe04e","type":"api-call-service","z":"c70d5be49b4d2a61","name":"ch8 on","server":"a52fadfc.d75d","version":3,"debugenabled":false,"service_domain":"switch","service":"turn_on","entityId":"switch.10013b653f_4","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":2730,"y":600,"wires":[["da5ce3213535c928"]]},{"id":"3229c0e4791e3d8a","type":"api-call-service","z":"c70d5be49b4d2a61","name":"ch8 off","server":"a52fadfc.d75d","version":3,"debugenabled":false,"service_domain":"switch","service":"turn_off","entityId":"switch.10013b653f_4","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":3690,"y":600,"wires":[["158f904138bb7ad9"]]},{"id":"158f904138bb7ad9","type":"change","z":"c70d5be49b4d2a61","name":"1123","rules":[{"t":"set","p":"payload","pt":"msg","to":"System Msg (1123): Ph went under 5.4, doser has been activated. Check status ASAP","tot":"str","dc":true}],"action":"","property":"","from":"","to":"","reg":false,"x":3850,"y":600,"wires":[[]]},{"id":"529f5ae2ce49085e","type":"change","z":"c70d5be49b4d2a61","name":"1133","rules":[{"t":"set","p":"payload","pt":"msg","to":"System Msg(1133): Conditions are Optimal","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":3850,"y":660,"wires":[["10e074596f4698d6"]]},{"id":"342242aec7fd9232","type":"change","z":"c70d5be49b4d2a61","name":"1143","rules":[{"t":"set","p":"payload","pt":"msg","to":"System Msg(1143): Pump or probe may need attention","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":3850,"y":700,"wires":[["10e074596f4698d6"]]},{"id":"6009a108c948f0b2","type":"api-call-service","z":"c70d5be49b4d2a61","name":"ch8/off","server":"a52fadfc.d75d","version":3,"debugenabled":false,"service_domain":"switch","service":"turn_off","entityId":"switch.10013b653f_4","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":3690,"y":700,"wires":[["342242aec7fd9232"]]},{"id":"aa0dee78c20d88f8","type":"change","z":"c70d5be49b4d2a61","name":"1111","rules":[{"t":"set","p":"payload","pt":"msg","to":"System Msg(1111) Time is incorrect. ALL Channels Have Been Shutdown!","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":3850,"y":760,"wires":[["10e074596f4698d6"]]},{"id":"da5ce3213535c928","type":"api-current-state","z":"c70d5be49b4d2a61","name":"ph up","server":"a52fadfc.d75d","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"input_number.ph_up","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":0,"forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":2970,"y":600,"wires":[["fe9de429aca99b54"]]},{"id":"fe9de429aca99b54","type":"calculator","z":"c70d5be49b4d2a61","name":"","inputMsgField":"payload","outputMsgField":"payload","operation":"div","constant":"0.83","round":false,"decimals":0,"x":3110,"y":600,"wires":[["bac5a26806b565ef"]]},{"id":"d0c03ec7cdef8946","type":"change","z":"c70d5be49b4d2a61","name":"","rules":[{"t":"set","p":"delay","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":3400,"y":600,"wires":[["55ecdb92325a24a0"]]},{"id":"55ecdb92325a24a0","type":"delay","z":"c70d5be49b4d2a61","name":"","pauseType":"delayv","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":3560,"y":600,"wires":[["3229c0e4791e3d8a"]]},{"id":"bac5a26806b565ef","type":"calculator","z":"c70d5be49b4d2a61","name":"","inputMsgField":"payload","outputMsgField":"payload","operation":"mult","constant":"1000","round":false,"decimals":0,"x":3240,"y":600,"wires":[["d0c03ec7cdef8946"]]},{"id":"459669f03e08c4a6","type":"change","z":"c70d5be49b4d2a61","name":"time is out of range","rules":[{"t":"set","p":"payload","pt":"msg","to":"Time Check Failed","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":3410,"y":720,"wires":[["aa0dee78c20d88f8"]]},{"id":"0014a165d02ced5c","type":"file","z":"c70d5be49b4d2a61","name":"BlueLogs","filename":"/config/BlueLogs.csv","appendNewline":true,"createDir":true,"overwriteFile":"false","encoding":"none","x":4160,"y":820,"wires":[["82cb39a857cddc90"]]},{"id":"10e074596f4698d6","type":"csv","z":"c70d5be49b4d2a61","name":"","sep":",","hdrin":"","hdrout":"none","multi":"one","ret":"\\n","temp":"","skip":"0","strings":true,"include_empty_strings":"","include_null_values":"","x":4030,"y":820,"wires":[["0014a165d02ced5c"]]},{"id":"82cb39a857cddc90","type":"debug","z":"c70d5be49b4d2a61","name":"file","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":4290,"y":820,"wires":[]},{"id":"7e5fcb5dd6ef1686","type":"moment","z":"c70d5be49b4d2a61","name":"T.stamp","topic":"timestamp","input":"","inputType":"msg","inTz":"America/New_York","adjAmount":0,"adjType":"days","adjDir":"add","format":"YYYY-MM-DD HH:mm:ss","locale":"C","output":"","outputType":"msg","outTz":"America/New_York","x":3560,"y":560,"wires":[["10e074596f4698d6"]]},{"id":"a52fadfc.d75d","type":"server","name":"Home Assistant","version":2,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30}]

@unborn this works start to finish

1 Like

@UnborN just wanted to thank you for all your help and guidance with node red, I seriously could not of crossed the finish line without your knowledge of this system and i truly appreciate it. Your swift intelligent responses that gave me direction when it was most needed. Im sure youll hear from me again with a "everything is lost" post but atm all systems are running as expected

                                                                                                   With utmost respect,
                                                                                                                                 Mikey

You are welcome. We all started Node-red the same way.
Experimenting, trying different things, reading on the Forum.
Every problem is a challenge and thats what makes programming fun.

I dont know if you already did but there is an introductory video playlist done by the developers of Node-red.
im sure you gonna up a trick or two
Node-RED Essentials

1 Like

on script runs twice then returns to normal on the 3rd process, even tho the 2nd time it runs the readings are in correct range to do nothing..is this common?

i could code in a function that kills the power to the system for the period of time it takes to straighten out, but seems weird it happens twice then fine.

i tried doubling delay timer to give it more time to register but it did not work it still doubled the function.

ideas welcomed

idea, use function to restart flow after "system on" is triggered

now to figure out how thats done..reading..reading..reading

can this be accomplished from the home assistant docker side of node red?

that not a solution ..
just because there is some problem in the logic of your flow it doesnt mean you have to restart it.
its better to see what the problem is.

its a hackjob fix i know

its gotta be a switch issue doesnt it? i hate switches

you are not giving us any information in order to help

  1. we dont know whats in the csv file
  2. based on the last flow you shared .. i dont undertand why you read the same grogreen csv twice
  3. why are there wires going across the flow from that inject node to trigger things further down.. when you could simply trigger them from the previous node ?
  4. In the Function node named "payload" you use code like content1 = msg.payload[0];
    as if you are still trying to access elements of an array .. yet the result of the Join node (set to Key/value) will be an Object.

sorry i was kinda just posting my thoughts as i was working this out, heres some info

csv it reads from:

2022-02-03 05:19:00,ppm500,F,1640,5.3,68
2022-02-03 05:20:00,ppm500,F,1630,5.3,68
2022-02-03 05:21:01,ppm500,F,1630,5.3,68
2022-02-03 05:22:00,ppm500,F,1650,5.5,68
2022-02-03 05:23:00,ppm500,F,1650,5.8,68
2022-02-03 05:24:00,ppm500,F,1650,5.9,68
2022-02-03 05:25:00,ppm500,F,1650,5.9,68
2022-02-03 05:26:00,ppm500,F,1660,5.9,68
2022-02-03 05:27:00,ppm500,F,1660,5.9,68
2022-02-03 05:28:00,ppm500,F,1660,6,68
2022-02-03 05:29:00,ppm500,F,1650,6,68
2022-02-03 05:30:00,ppm500,F,1650,6,68
2022-02-03 05:31:00,ppm500,F,1660,6,68
2022-02-03 05:32:00,ppm500,F,1660,6,68
2022-02-03 05:33:00,ppm500,F,1650,6,68
2022-02-03 05:34:00,ppm500,F,1660,6,68
2022-02-03 05:35:00,ppm500,F,1650,6,68
2022-02-03 05:36:00,ppm500,F,1660,6,68

out log

{"col1":"2022-02-03 05:20:20"}
{"col1":"System Msg (1132): Within Recommended Levels"}
{"col1":"System Msg (1123): Ph went under 5.4","col2":" doser has been activated. Check status ASAP"}
{"col1":"2022-02-03 05:32:20"}
{"col1":"System Msg (1132): Within Recommended Levels"}
{"col1":"System Msg (1123): Ph went under 5.4","col2":" doser has been activated. Check status ASAP"}
{"col1":"2022-02-03 05:44:20"}
{"col1":"System Msg(1133): Conditions are Optimal"}
{"col1":"System Msg (1132): Within Recommended Levels"}
{"col1":"2022-02-03 05:56:20"}
{"col1":"System Msg(1133): Conditions are Optimal"}
{"col1":"System Msg (1132): Within Recommended Levels"}
{"col1":"2022-02-03 06:08:20"}
{"col1":"System Msg(1133): Conditions are Optimal"}
{"col1":"System Msg (1132): Within Recommended Levels"}

you can see at 5:32 am it was within range and still activated the system

i wanted it to drop a time stamp in that file, it marks as like a header before each process is run i seen an easy method to inject it before anything else so i used it

i was trying something like that before but wasnt returning the file as i wanted it and this gave me the output i desired

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