brianllong
(Brian Long)
October 15, 2018, 7:54pm
1
Ive been working with this flow for sometime now and it works well so i thought id share it. So if anyone has any suggestion or improvement im open to hearing them.
flow.code
[
{
"id": "d56f2928.0e12a8",
"type": "function",
"z": "434680e7.ed33e",
"name": "Low Level Timeprop",
"func": "// A node that can be used to generate a time proportioned on/off signal\n// from a power requirement value in the range 0 to 1\n// So for example with a cycle time period (set below) of 10 minutes and\n// a power requirement of 0.2 the output will be on for 2 minutes in every\n// ten minutes.\n// In addition to passing in messages with the payload set to the current\n// power requirement (floating point 0.0 to 1.0), provide an input from a \n// repeating inject node with the topic set to 'tick' and the payload \n// containing the current timestamp. The frequency of this will depend upon \n// the cycle time required. For a cycle time period of 10 minutes I use an inject\n// repeat of 5 seconds.\n\n// Set these three variables as required\nvar period = 10*60*1000; // On/off cycle time period millisecs, 10 minutes\nvar deadTime = 30*1000; // number of milliseconds the valve (or whatever) takes to actuate, 30 seconds\nvar invert = false; // set true for active low output, so the output will go low\n // when the valve should actuate, this is the usual case on a\n // pi feeding a relay to drive the actuator\n\n// is this a tick message?\nif (msg.topic !== \"tick\") {\n // no, so it should be a power value, save it and exit\n var power = msg.payload;\n context.set('power', msg.payload);\n msg = null;\n} else {\n // yes, payload is timestamp, calc current wave value between 0 and 1\n var wave = (msg.payload % period)/period; // fraction of way through cycle\n var direction;\n // determine direction of travel and convert to triangular wave\n if (wave < 0.5) {\n direction = 1; // on the way up\n wave = wave*2;\n } else {\n direction = -1; // on the way down\n wave = (1 - wave)*2;\n }\n var requestedPower = context.get('power') || 0;\n // if a dead_time has been supplied for this o/p then adjust power accordingly\n if (deadTime > 0 && requestedPower > 0.0 && requestedPower < 1.0) {\n var dtop = deadTime/period;\n power = (1.0-2.0*dtop)*requestedPower + dtop;\n } else {\n power = requestedPower;\n }\n // cope with end cases in case values outside 0..1\n var opState;\n if (power <= 0.0) {\n opState = 0; // no heat\n } else if (power >= 1.0) {\n opState = 1; // full heat\n } else {\n // only allow power to come on on the way down and off on the way up, to reduce short pulses\n if (power >= wave && direction === -1) {\n opState = 1;\n } else if (power <= wave && direction === 1) {\n opState = 0;\n } else {\n // otherwise leave it as it is\n opState = context.get('opState') || 0;\n } \n }\n context.set('opState', opState);\n msg.payload = invert ? (1-opState) : opState;\n}\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 2931.638870239258,
This file has been truncated. show original
Gad_Ofir
(Gad Ofir)
October 15, 2018, 9:15pm
2
Hi i am missing allot of nodes there , do you know how can i tell what i am missing
alwys love to see a node red flow
brianllong
(Brian Long)
October 15, 2018, 9:53pm
3
did you copy it from github? try clicking the raw then copying the source
Gad_Ofir
(Gad Ofir)
October 16, 2018, 6:11pm
4
yes but you have nodes that i dont have so i cannot see all…
Updated Github, fan controls now query localweather to override window fan if weather conditions change
flow.code
[
{
"id": "434680e7.ed33e",
"type": "tab",
"label": "Bedroom Control",
"disabled": false,
"info": ""
},
{
"id": "4132b2a1.4b86cc",
This file has been truncated. show original