This article will explain how we implemented Industrial Automation based on Node-RED and Raspberry Pi using Node-RED Dashboard. We have implemented the device in a rebar wood processing factory. Specifically, we have installed a device to control the wood dryer chamber. The environmental data to be considered are temperature and humidity in the room.
![]() |
Industrial Automation |
Industrial Automation
This is the age of the 4th industrial evaluation. Industry 4.0 is growing fast. It includes massive improvement of industries empowered by IoT, data mining, and machine learning. The IoT is now moving to IIoT(Industrial Internet of Things). Now we have the customized Raspberry Pi version, Revolution Pi, for the industrial Internet of Things.
Node-RED and Raspberry Pi
Node-RED is an IoT platform introduced by IBM based on node.js. This flow-based programming platform collects, stores, analyzes, manages, controls the data flow, and executes logical operations based on the instruction set.
Raspberry Pi is a very popular mini-computer with both processing and controlling features. This characteristic made it IoT friendly device. It can be used as an IoT server to communicate with sensors, industrial machines, the client through MQTT protocols, and a Wi-Fi network.
Industrial Automation using Node-RED Dashboard and Raspberry Pi
As Node-RED is an IoT tool and Raspberry Pi can be used as a controller and processor, we can deploy Node-RED and Raspberry Pi to collect sensor data. We can control the dryer fan, heater, spray, and flap to dehumidify based on the sensor and user-defined data from the Node-RED dashboard.
We have used the Arduino Ethernet shield to collect sensor data. After collecting data, Arduino will send data to Raspberry Pi through the MQTT protocol.
The code for Arduino ethernet shield:
#include <Ethernet.h> | |
#include <PubSubClient.h> | |
#include <OneWire.h> | |
#include <DallasTemperature.h> | |
#include "DHT.h" | |
const int oneWireBus = 8; | |
float temp; | |
float tempSensor1; | |
float tempSensor2; | |
float humSensor1; | |
float humSensor2; | |
// Setup a oneWire instance to communicate with any OneWire devices | |
OneWire oneWire(oneWireBus); | |
// Pass our oneWire reference to Dallas Temperature sensor | |
DallasTemperature sensors(&oneWire); | |
int numberOfDevices; | |
DeviceAddress tempDeviceAddress; | |
#define DHTPIN0 2 // Digital pin connected to the DHT sensor | |
#define DHTPIN1 3 // Digital pin connected to the DHT sensor | |
//#define DHTTYPE DHT11 // DHT 11 | |
#define DHTTYPE0 DHT21 // DHT 22 (AM2302), AM2321 | |
#define DHTTYPE1 DHT21 // DHT 22 (AM2302), AM2321 | |
DHT dht0(DHTPIN0, DHTTYPE0); | |
DHT dht1(DHTPIN1, DHTTYPE1); | |
// This MAC addres can remain the same | |
byte mac[] = { 0xDE, 0xED, 0xBA, 0xFE, 0xFE, 0xED }; | |
IPAddress ip(192, 168, 5, 110); | |
//IPAddress myDns(202,191,120, 2); | |
//IPAddress gateway(10, 30, 0, 1); | |
//IPAddress subnet(255, 0, 0, 0); | |
// Replace with your Raspberry Pi IP Address. In my case, the RPi IP Address is 192.168.1.76 | |
IPAddress server(192, 168, 5, 101); | |
// Initializes the variables | |
EthernetClient ethClient_hvac; | |
PubSubClient client(ethClient_hvac); | |
char Hum[10]; | |
char Tem[10]; | |
char Hum1[10]; | |
char Tem1[10]; | |
char Hum2[10]; | |
char Tem2[10]; | |
void callback(char* topic, byte* message, unsigned int length) { | |
Serial.print("Message arrived on topic: "); | |
Serial.print(topic); | |
Serial.print(". Message: "); | |
String messageTemp; | |
for (int i = 0; i < length; i++) { | |
Serial.print((char)message[i]); | |
messageTemp += (char)message[i]; | |
} | |
Serial.println(); | |
} | |
// Change the function below if you want to subscribe to more topics with your Arduino | |
void reconnect() { | |
// Loop until we're reconnected | |
while (!client.connected()) { | |
Serial.print("Attempting MQTT connection..."); | |
// Attempt to connect | |
if (client.connect("arduinoClient_HVAC_Meter")) { | |
Serial.println("connected"); | |
} else { | |
Serial.print("failed, rc="); | |
Serial.print(client.state()); | |
Serial.println(" try again in 5 seconds"); | |
// Wait 5 seconds before retrying | |
delay(5000); | |
} | |
} | |
} | |
void setup() | |
{ | |
//Serial.begin(115200); | |
client.setServer(server, 1883); | |
client.setCallback(callback); | |
sensors.begin(); | |
dht0.begin(); | |
dht1.begin(); | |
Ethernet.begin(mac, ip); | |
numberOfDevices = sensors.getDeviceCount(); | |
Serial.print("Locating devices..."); | |
Serial.print("Found "); | |
Serial.print(numberOfDevices, DEC); | |
Serial.println(" devices."); | |
// Loop through each device, print out address | |
for (int i = 0; i < numberOfDevices; i++) { | |
// Search the wire for address | |
if (sensors.getAddress(tempDeviceAddress, i)) { | |
Serial.print("Found device "); | |
Serial.print(i, DEC); | |
Serial.print(" with address: "); | |
printAddress(tempDeviceAddress); | |
Serial.println(); | |
} else { | |
Serial.print("Found ghost device at "); | |
Serial.print(i, DEC); | |
Serial.print(" but could not detect address. Check power and cabling"); | |
} | |
} | |
} | |
void loop() | |
{ | |
if (!client.connected()) { | |
reconnect(); | |
} | |
client.loop(); | |
totalTemp(); | |
float tempA = temp / numberOfDevices; | |
Serial.println("=================="); | |
Serial.print("Temperature Avarage for 2 device: "); | |
Serial.println(tempA); | |
Serial.println("=================="); | |
float humAvg = totalHum() / 2; | |
Serial.println("=================="); | |
Serial.print("Humidity Avarage for 2 device: "); | |
Serial.println(humAvg); | |
Serial.println("=================="); | |
dtostrf(tempA, 4, 0, Tem); | |
dtostrf(humAvg, 4, 0, Hum); | |
// Publishes a new Temperature value | |
//client.publish("topic_temp", Tem); | |
//client.publish("topic_hum", Hum); | |
client.publish("topic_temp_1", Tem1); | |
client.publish("topic_temp_2", Tem2); | |
client.publish("topic_hum_1", Hum1); | |
client.publish("topic_hum_2", Hum2); | |
delay(5000); | |
} | |
void totalTemp() { | |
sensors.requestTemperatures(); // Send the command to get temperatures | |
delay(10); | |
temp = 0; | |
// Loop through each device, print out temperature data | |
for (int i = 0; i < numberOfDevices; i++) { | |
if (sensors.getAddress(tempDeviceAddress, i)) { | |
// Output the device ID | |
Serial.print("Temperature for device: "); | |
Serial.println(i, DEC); | |
// Print the data | |
float tempC = sensors.getTempC(tempDeviceAddress); | |
Serial.print("Temp C: "); | |
Serial.println(tempC); | |
if (i == 0) { | |
tempSensor1 = tempC; | |
dtostrf(tempSensor1, 4, 0, Tem1); | |
} else { | |
tempSensor2 = tempC; | |
dtostrf(tempSensor2, 4, 0, Tem2); | |
} | |
temp = temp + tempC; | |
} | |
} | |
if ( temp <= 20) { | |
Serial.println(F("Not Proper Value from Temp sensor!")); | |
return; | |
} | |
} | |
// function to print a device address | |
void printAddress(DeviceAddress deviceAddress) { | |
for (uint8_t i = 0; i < 8; i++) { | |
if (deviceAddress[i] < 16) Serial.print("0"); | |
Serial.print(deviceAddress[i], HEX); | |
} | |
} | |
float totalHum() { | |
float totalHum = 0; | |
float h0 = dht0.readHumidity(); | |
float t0 = dht0.readTemperature(); | |
float f0 = dht0.readTemperature(true); | |
float h1 = dht1.readHumidity(); | |
float t1 = dht1.readTemperature(); | |
float f1 = dht1.readTemperature(true); | |
//Check if any reads failed and exit early (to try again). | |
if (isnan(h0) || isnan(t0) || isnan(f0)) { | |
Serial.println(F("Failed to read from DHT sensor!")); | |
return; | |
} else { | |
Serial.print("Humidity 1: "); | |
Serial.println(h0); | |
humSensor1 = h0; | |
dtostrf(humSensor1, 4, 0, Hum1); | |
} | |
float hif0 = dht0.computeHeatIndex(f0, h0); | |
float hic0 = dht0.computeHeatIndex(t0, h0, false); | |
//Check if any reads failed and exit early (to try again). | |
if (isnan(h1) || isnan(t1) || isnan(f1)) { | |
Serial.println(F("Failed to read from DHT sensor!")); | |
return; | |
} | |
else { | |
Serial.print("Humidity 2: "); | |
Serial.println(h1); | |
humSensor2 = h1; | |
dtostrf(humSensor2, 4, 0, Hum2); | |
} | |
float hif1 = dht1.computeHeatIndex(f1, h1); | |
float hic1 = dht1.computeHeatIndex(t1, h1, false); | |
totalHum = h0 + h1; | |
Serial.println(); | |
return totalHum; | |
} |
The raspberry pi displays the node-RED dashboard. Users can set data from the Raspberry Pi touch display easily. The Node-RED dashboard looks like the following.
The Node-RED flow is given below:
[{"id":"e893dd92.e5f428","type":"tab","label":"BIFDC","disabled":true,"info":""},{"id":"3f266560.cbf812","type":"tab","label":"Admin","disabled":true,"info":""},{"id":"ed72f8b2.cea9c8","type":"tab","label":"Auto/Manual","disabled":false,"info":""},{"id":"34243684.8b511a","type":"tab","label":"User Input","disabled":false,"info":""},{"id":"fc826377.b12ce","type":"tab","label":"MachineOut","disabled":false,"info":""},{"id":"e661d7b9.d19188","type":"tab","label":"Sensor Data","disabled":false,"info":""},{"id":"bdd9cacd.0c9dd8","type":"tab","label":"Fan CW","disabled":false,"info":""},{"id":"d20f0197.c2ede","type":"tab","label":"Fan CCW","disabled":false,"info":""},{"id":"4f9abcfd.bbeea4","type":"subflow","name":"Timer Settings (2)","info":"","category":"","in":[{"x":500,"y":320,"wires":[{"id":"58fe76f3.60adb8"}]}],"out":[{"x":740,"y":320,"wires":[{"id":"58fe76f3.60adb8","port":0}]}],"env":[{"name":"TimerNumber","type":"num","value":""},{"name":"PayloadON","type":"str","value":""},{"name":"PayloadOFF","type":"str","value":""}],"color":"#DDAA99"},{"id":"7aaed9dd.cbefe8","type":"ui_base","theme":{"name":"theme-dark","lightTheme":{"default":"#0094CE","baseColor":"#0094CE","baseFont":"-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif","edited":true,"reset":false},"darkTheme":{"default":"#097479","baseColor":"#097479","baseFont":"-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif","edited":true,"reset":false},"customTheme":{"name":"Untitled Theme 1","default":"#4B7930","baseColor":"#4B7930","baseFont":"-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif"},"themeState":{"base-color":{"default":"#097479","value":"#097479","edited":false},"page-titlebar-backgroundColor":{"value":"#097479","edited":false},"page-backgroundColor":{"value":"#111111","edited":false},"page-sidebar-backgroundColor":{"value":"#000000","edited":false},"group-textColor":{"value":"#0eb8c0","edited":false},"group-borderColor":{"value":"#555555","edited":false},"group-backgroundColor":{"value":"#333333","edited":false},"widget-textColor":{"value":"#eeeeee","edited":false},"widget-backgroundColor":{"value":"#097479","edited":false},"widget-borderColor":{"value":"#333333","edited":false},"base-font":{"value":"-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif"}},"angularTheme":{"primary":"indigo","accents":"blue","warn":"red","background":"grey"}},"site":{"name":"Node-RED Dashboard","hideToolbar":"false","allowSwipe":"false","lockMenu":"false","allowTempTheme":"true","dateFormat":"DD/MM/YYYY","sizes":{"sx":48,"sy":48,"gx":6,"gy":6,"cx":6,"cy":6,"px":0,"py":0}}},{"id":"ecdfb718.844138","type":"ui_group","z":"","name":"Auto/Manual","tab":"","order":4,"disp":true,"width":"6","collapse":false},{"id":"4aee772d.de27a8","type":"mqtt-broker","z":"","name":"","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthRetain":"false","birthPayload":"","closeTopic":"","closeQos":"0","closeRetain":"false","closePayload":"","willTopic":"","willQos":"0","willRetain":"false","willPayload":""},{"id":"e45b5db9.36a54","type":"ui_group","z":"","name":"User Input","tab":"","order":1,"disp":true,"width":"6","collapse":false},{"id":"f63fceb2.278a7","type":"mqtt-broker","z":"","name":"","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthRetain":"false","birthPayload":"","closeTopic":"","closeQos":"0","closeRetain":"false","closePayload":"","willTopic":"","willQos":"0","willRetain":"false","willPayload":""},{"id":"f8d6beaf.06bc","type":"mqtt-broker","z":"","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthRetain":"false","birthPayload":"","willTopic":"","willQos":"0","willRetain":"false","willPayload":""},{"id":"667f47ab.1f09d8","type":"mqtt-broker","z":"","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthRetain":"false","birthPayload":"","willTopic":"","willQos":"0","willRetain":"false","willPayload":""},{"id":"d392b557.00e6b","type":"ui_group","z":"","name":"Auto Status","tab":"","order":3,"disp":true,"width":"6","collapse":false},{"id":"c3711ff9.3ee378","type":"ui_group","z":"","name":"Live Data","tab":"","order":2,"disp":true,"width":"6","collapse":false},{"id":"3ed10064.8bc86","type":"mqtt-broker","z":"","name":"","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthRetain":"false","birthPayload":"","closeTopic":"","closeQos":"0","closeRetain":"false","closePayload":"","willTopic":"","willQos":"0","willRetain":"false","willPayload":""},{"id":"d704bfab.90376","type":"mqtt-broker","z":"","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthRetain":"false","birthPayload":"","willTopic":"","willQos":"0","willRetain":"false","willPayload":""},{"id":"87930ea4.2aca3","type":"ui_tab","z":"","name":"BFIDC","icon":"dashboard","order":2,"disabled":false,"hidden":false},{"id":"2c8ed61a.6d4a0a","type":"ui_group","z":"","name":"Auto/Manual","tab":"87930ea4.2aca3","order":1,"disp":true,"width":"6","collapse":false},{"id":"ce8a762f.5f9e78","type":"ui_group","z":"","name":"Live Temperature","tab":"87930ea4.2aca3","order":6,"disp":true,"width":"6","collapse":false},{"id":"a49581bc.969ee","type":"ui_group","z":"","name":"Live Humidity","tab":"87930ea4.2aca3","order":7,"disp":true,"width":"6","collapse":false},{"id":"b910ffa2.541dd","type":"ui_group","z":"","name":"User Input","tab":"87930ea4.2aca3","order":2,"disp":true,"width":"6","collapse":false},{"id":"9bc4db16.969488","type":"ui_group","z":"","name":"Fan Control CW","tab":"87930ea4.2aca3","order":3,"disp":true,"width":"6","collapse":false},{"id":"3e388c09.956444","type":"ui_group","z":"","name":"Fan Control CCW","tab":"87930ea4.2aca3","order":4,"disp":true,"width":"6","collapse":false},{"id":"781b9643.959bc8","type":"mqtt-broker","z":"","name":"DreamHome","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthRetain":"false","birthPayload":"","closeTopic":"","closeQos":"0","closeRetain":"false","closePayload":"","willTopic":"","willQos":"0","willRetain":"false","willPayload":""},{"id":"6e6cb675.3a4b58","type":"ui_tab","z":"","name":"Status","icon":"dashboard","order":2,"disabled":false,"hidden":false},{"id":"66f5af7f.b94058","type":"ui_group","z":"","name":"Temperature Data","tab":"6e6cb675.3a4b58","order":1,"disp":true,"width":"6","collapse":false},{"id":"cb463a47.03cb98","type":"ui_group","z":"","name":"Humidity Data","tab":"6e6cb675.3a4b58","order":2,"disp":true,"width":"6","collapse":false},{"id":"6c2b803e.b7681","type":"ui_group","z":"","name":"Time","tab":"6e6cb675.3a4b58","order":3,"disp":true,"width":"6","collapse":false},{"id":"58fe76f3.60adb8","type":"function","z":"4f9abcfd.bbeea4","name":"","func":"var x = env.get(\"TimerNumber\"); \nvar y = env.get(\"PayloadON\"); \nvar z = env.get(\"PayloadOFF\"); \n\nflow.set(\"$parent.Timer\"+x, x);\nflow.set(\"$parent.Payload\"+x+\"_on\", y);\nflow.set(\"$parent.Payload\"+x+\"_off\", z);\n\n\n\nmsg.payload = \"Your timer \" + x + \" has been set\";\n\nreturn msg;\n","outputs":1,"noerr":0,"x":600,"y":320,"wires":[[]]},{"id":"159061ba.5a46de","type":"function","z":"e893dd92.e5f428","name":"","func":"const override = global.get(\"AutoManual_switch\") || 0;\nmsg.payload =override ;\nreturn msg;","outputs":1,"noerr":0,"x":240,"y":380,"wires":[["80bb15da.6439d8"]]},{"id":"753a997d.1accc","type":"inject","z":"e893dd92.e5f428","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":70,"y":380,"wires":[["159061ba.5a46de"]]},{"id":"80bb15da.6439d8","type":"debug","z":"e893dd92.e5f428","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":430,"y":380,"wires":[]},{"id":"4b5a16f1.8a043","type":"change","z":"e893dd92.e5f428","name":"","rules":[{"t":"change","p":"payload","pt":"msg","from":"auto","fromt":"str","to":"Auto","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"manual","fromt":"str","to":"Manual","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":680,"y":80,"wires":[["bdc3c392.ef95d8","dc595789.ec3738"]]},{"id":"b8ad12f3.2182e","type":"change","z":"e893dd92.e5f428","name":"Auto/Manual var","rules":[{"t":"set","p":"AutoManual_switch","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":900,"y":140,"wires":[[]]},{"id":"f15ea629.db99d","type":"change","z":"e893dd92.e5f428","name":"","rules":[{"t":"change","p":"payload","pt":"msg","from":"manual","fromt":"str","to":"1","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":700,"y":280,"wires":[["4eb16102.1fcc58"]]},{"id":"bdc3c392.ef95d8","type":"ui_text","z":"e893dd92.e5f428","group":"ecdfb718.844138","order":2,"width":"0","height":"0","name":"manualText","label":"Mode","format":"{{msg.payload}}","layout":"row-spread","x":870,"y":80,"wires":[]},{"id":"1e80c25d.a4c98e","type":"debug","z":"e893dd92.e5f428","name":"Output to GPIO","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":680,"y":340,"wires":[]},{"id":"9ad42041.d76c58","type":"function","z":"e893dd92.e5f428","name":"turn on override","func":"const override = global.get(\"AutoManual_switch\") || 0;\nif(override === 0){\n msg.payload = \"manual\";\n return msg;\n} else {\n return null;\n}","outputs":1,"noerr":0,"x":680,"y":200,"wires":[["4b5a16f1.8a043","4fb2abdb.a45c44"]]},{"id":"8d8eba4c.fea23","type":"switch","z":"e893dd92.e5f428","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"auto","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":410,"y":220,"wires":[["4b5a16f1.8a043","4602409.c21964","998dd111.2d1a8"],["9ad42041.d76c58","f15ea629.db99d","1e80c25d.a4c98e"]]},{"id":"4602409.c21964","type":"change","z":"e893dd92.e5f428","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"0","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":680,"y":140,"wires":[["b8ad12f3.2182e"]]},{"id":"a1484930.31ed3","type":"inject","z":"e893dd92.e5f428","name":"","topic":"","payload":"auto","payloadType":"str","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":70,"y":220,"wires":[["e8e09569.a42678"]]},{"id":"998dd111.2d1a8","type":"debug","z":"e893dd92.e5f428","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":410,"y":160,"wires":[]},{"id":"4eb16102.1fcc58","type":"debug","z":"e893dd92.e5f428","name":"Output to GPIO","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":960,"y":320,"wires":[]},{"id":"4fb2abdb.a45c44","type":"change","z":"e893dd92.e5f428","name":"","rules":[{"t":"change","p":"payload","pt":"msg","from":"manual","fromt":"str","to":"1","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":900,"y":220,"wires":[["b8ad12f3.2182e","80c63bb7.0b312"]]},{"id":"80c63bb7.0b312","type":"debug","z":"e893dd92.e5f428","name":"Output to GPIO","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":1160,"y":220,"wires":[]},{"id":"42ef1cd2.cebbb4","type":"ui_switch","z":"e893dd92.e5f428","name":"","label":"Heater","tooltip":"","group":"ecdfb718.844138","order":3,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"heater","style":"","onvalue":"0","onvalueType":"str","onicon":"","oncolor":"","offvalue":"1","offvalueType":"str","officon":"","offcolor":"","x":370,"y":580,"wires":[["f0516c3b.ef9ae","6c2da4aa.bd2cc4"]]},{"id":"6c2da4aa.bd2cc4","type":"function","z":"e893dd92.e5f428","name":"","func":"const Temp_topic = msg.topic;\nconst Temp_payload = msg.payload;\nconst override = global.get(\"AutoManual_switch\") || 0;\nconst fanstate = global.get(\"FanState\");\nif (override !== 0) {\n if (Temp_topic === \"heater\" && Temp_payload === \"0\") {\n msg.payload = 0;\n global.set(\"heaterState\", msg.payload);\n return msg;\n } else if(Temp_topic === \"heater\" && Temp_payload === \"1\") {\n msg.payload = 1;\n global.set(\"heaterState\", msg.payload);\n return msg;\n } else if(Temp_topic === \"spray\" && Temp_payload === \"0\") {\n msg.payload = 0;\n global.set(\"sprayState\", msg.payload);\n return msg;\n } else if(Temp_topic === \"spray\" && Temp_payload === \"1\") {\n msg.payload = 1;\n global.set(\"sprayState\", msg.payload);\n return msg;\n } else if(Temp_topic === \"fancw\" && Temp_payload === \"0\") {\n msg.payload = 0;\n global.set(\"fancwState\", msg.payload);\n return msg;\n } else if(Temp_topic === \"fancw\" && Temp_payload === \"1\") {\n msg.payload = 1;\n global.set(\"fancwState\", msg.payload);\n return msg;\n } else if(Temp_topic === \"fanccw\" && Temp_payload === \"0\") {\n msg.payload = 0;\n global.set(\"fanccwState\", msg.payload);\n return msg; \n } else if(Temp_topic === \"fanccw\" && Temp_payload === \"1\") {\n msg.payload = 1;\n global.set(\"fanccwState\", msg.payload);\n return msg; \n } else if(Temp_topic === \"flap/open\" && Temp_payload === \"0\") {\n msg.payload = 0;\n global.set(\"flap_openState\", msg.payload);\n return msg;\n } else if(Temp_topic === \"flap/open\" && Temp_payload === \"1\") {\n msg.payload = 1;\n global.set(\"flap_openState\", msg.payload);\n return msg;\n } else if(Temp_topic === \"flap/close\" && Temp_payload === \"0\") {\n msg.payload = 0;\n global.set(\"flap_closeState\", msg.payload);\n return msg;\n } else if(Temp_topic === \"flap/close\" && Temp_payload === \"1\") {\n msg.payload = 1;\n global.set(\"flap_closeState\", msg.payload);\n return msg;\n } else {\n return null;\n }\n}\n\n","outputs":1,"noerr":0,"x":590,"y":580,"wires":[["2ffe8532.b7afd2"]]},{"id":"f0516c3b.ef9ae","type":"debug","z":"e893dd92.e5f428","name":"","active":false,"tosidebar":true,"console":false,"tostatus":true,"complete":"true","targetType":"full","x":450,"y":500,"wires":[]},{"id":"2ffe8532.b7afd2","type":"debug","z":"e893dd92.e5f428","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":770,"y":520,"wires":[]},{"id":"25c786f3.17a65a","type":"ui_switch","z":"e893dd92.e5f428","name":"","label":"Spray","tooltip":"","group":"ecdfb718.844138","order":3,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"spray","style":"","onvalue":"0","onvalueType":"str","onicon":"","oncolor":"","offvalue":"1","offvalueType":"str","officon":"","offcolor":"","x":370,"y":660,"wires":[["6c2da4aa.bd2cc4"]]},{"id":"5d98398c.6ebab","type":"ui_switch","z":"e893dd92.e5f428","name":"","label":"Flap_open","tooltip":"","group":"ecdfb718.844138","order":3,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"flap/open","style":"","onvalue":"0","onvalueType":"str","onicon":"","oncolor":"","offvalue":"1","offvalueType":"str","officon":"","offcolor":"","x":390,"y":840,"wires":[["6c2da4aa.bd2cc4"]]},{"id":"8fc093f4.892348","type":"ui_switch","z":"e893dd92.e5f428","name":"","label":"Flap_close","tooltip":"","group":"ecdfb718.844138","order":3,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"flap/close","style":"","onvalue":"0","onvalueType":"str","onicon":"","oncolor":"","offvalue":"1","offvalueType":"str","officon":"","offcolor":"","x":390,"y":900,"wires":[["6c2da4aa.bd2cc4"]]},{"id":"efeb9417.ba1218","type":"ui_switch","z":"e893dd92.e5f428","name":"","label":"FanCW","tooltip":"","group":"ecdfb718.844138","order":3,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"fancw","style":"","onvalue":"0","onvalueType":"str","onicon":"","oncolor":"","offvalue":"1","offvalueType":"str","officon":"","offcolor":"","x":380,"y":720,"wires":[["6c2da4aa.bd2cc4"]]},{"id":"4939e8a5.91cb","type":"ui_switch","z":"e893dd92.e5f428","name":"","label":"FanCCW","tooltip":"","group":"ecdfb718.844138","order":3,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"fanccw","style":"","onvalue":"0","onvalueType":"str","onicon":"","oncolor":"","offvalue":"1","offvalueType":"str","officon":"","offcolor":"","x":380,"y":780,"wires":[["6c2da4aa.bd2cc4"]]},{"id":"5c5e4f04.4d8828","type":"debug","z":"e893dd92.e5f428","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":230,"y":480,"wires":[]},{"id":"48024e91.8c7ec","type":"function","z":"e893dd92.e5f428","name":"","func":"const heater = global.get(\"heaterState\") || 0;\nmsg.payload = heater ;\nreturn msg;","outputs":1,"noerr":0,"x":360,"y":980,"wires":[["e73d6911.9b16d8"]]},{"id":"664d56d2.8d60c8","type":"inject","z":"e893dd92.e5f428","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":190,"y":980,"wires":[["48024e91.8c7ec"]]},{"id":"e73d6911.9b16d8","type":"debug","z":"e893dd92.e5f428","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":550,"y":980,"wires":[]},{"id":"e8e09569.a42678","type":"ui_dropdown","z":"e893dd92.e5f428","name":"","label":"","tooltip":"","place":"Select option","group":"ecdfb718.844138","order":1,"width":0,"height":0,"passthru":true,"options":[{"label":"AUTO","value":"auto","type":"str"},{"label":"MANUAL","value":"manual","type":"str"}],"payload":"","topic":"","x":250,"y":220,"wires":[["8d8eba4c.fea23"]]},{"id":"86f1306e.7d81b","type":"inject","z":"e893dd92.e5f428","name":"ON","topic":"","payload":"on","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":750,"y":780,"wires":[["fb81b622.c58848"]]},{"id":"fb81b622.c58848","type":"ui_switch","z":"e893dd92.e5f428","d":true,"name":"","label":"switch","tooltip":"","group":"","order":10,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"","style":"","onvalue":"on","onvalueType":"str","onicon":"","oncolor":"","offvalue":"off","offvalueType":"str","officon":"","offcolor":"","x":890,"y":780,"wires":[["6ca77c90.74e8cc"]]},{"id":"6ca77c90.74e8cc","type":"debug","z":"e893dd92.e5f428","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":1050,"y":780,"wires":[]},{"id":"5e69a0cd.736db","type":"inject","z":"e893dd92.e5f428","name":"OFF","topic":"","payload":"off","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":750,"y":840,"wires":[["fb81b622.c58848"]]},{"id":"aa18d3c7.85d3a","type":"mqtt out","z":"e893dd92.e5f428","name":"","topic":"reset","qos":"","retain":"","broker":"4aee772d.de27a8","x":930,"y":20,"wires":[]},{"id":"84b22584.8503c8","type":"inject","z":"e893dd92.e5f428","name":"","topic":"","payload":"1","payloadType":"str","repeat":"","crontab":"","once":true,"onceDelay":"1","x":170,"y":700,"wires":[["42ef1cd2.cebbb4","25c786f3.17a65a","efeb9417.ba1218","4939e8a5.91cb","5d98398c.6ebab","8fc093f4.892348"]]},{"id":"dc595789.ec3738","type":"change","z":"e893dd92.e5f428","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"1","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":740,"y":20,"wires":[["aa18d3c7.85d3a"]]},{"id":"8a79ce76.fed49","type":"mqtt in","z":"e893dd92.e5f428","name":"","topic":"reset","qos":"2","datatype":"auto","broker":"4aee772d.de27a8","x":100,"y":580,"wires":[["42ef1cd2.cebbb4","25c786f3.17a65a","efeb9417.ba1218","4939e8a5.91cb","5d98398c.6ebab","8fc093f4.892348","5c5e4f04.4d8828"]]},{"id":"83908094.974408","type":"function","z":"3f266560.cbf812","name":"Time","func":"var Set_time= {\"payload\":msg.payload.SetTime};\n\n//flow.set('order_id', O_rderID);\n//msg.topic='Set_Temp'\n\nreturn Set_time;","outputs":1,"noerr":0,"x":270,"y":160,"wires":[["692f1390.fe8d1c"]]},{"id":"38130d2d.65fcfa","type":"comment","z":"3f266560.cbf812","name":"User Input","info":"","x":280,"y":40,"wires":[]},{"id":"ffff68c8.fa6a58","type":"ui_form","z":"3f266560.cbf812","name":"","label":"","group":"e45b5db9.36a54","order":1,"width":0,"height":0,"options":[{"label":"Temperature","value":"SetTemperature","type":"text","required":true,"rows":null},{"label":"Humidity","value":"SetHumidity","type":"text","required":true,"rows":null},{"label":"Time","value":"SetTime","type":"text","required":true,"rows":null}],"formValue":{"SetTemperature":"","SetHumidity":"","SetTime":""},"payload":"","submit":"Submit","cancel":"Cancel","topic":"","x":70,"y":100,"wires":[["329f9a41.394976","ab800d21.e432d","83908094.974408","993d22e5.f7ed8","69b02f34.e2258"]]},{"id":"329f9a41.394976","type":"function","z":"3f266560.cbf812","name":"Temp","func":"var Set_temp= {\"payload\":msg.payload.SetTemperature};\n\n//flow.set('order_id', O_rderID);\n//msg.topic='Set_Temp'\n\nreturn Set_temp;","outputs":1,"noerr":0,"x":270,"y":80,"wires":[["7e4fb83b.3e2d5","6ed16269.64f85c","21c1c499.e93c34"]]},{"id":"ab800d21.e432d","type":"function","z":"3f266560.cbf812","name":"Hum","func":"var Set_hum = {\"payload\":msg.payload.SetHumidity};\n\n//flow.set('order_id', O_rderID);\n//msg.topic='Set_Temp'\n\nreturn Set_hum;","outputs":1,"noerr":0,"x":270,"y":120,"wires":[["57bf3d6a.7bc434","b4e88eb4.50d2e8"]]},{"id":"993d22e5.f7ed8","type":"debug","z":"3f266560.cbf812","name":"","active":false,"console":"false","complete":"false","x":290,"y":220,"wires":[]},{"id":"7e4fb83b.3e2d5","type":"debug","z":"3f266560.cbf812","name":"","active":true,"console":"false","complete":"false","x":450,"y":40,"wires":[]},{"id":"6ed16269.64f85c","type":"change","z":"3f266560.cbf812","name":"SetTemperature","rules":[{"t":"set","p":"temperature/set","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":460,"y":80,"wires":[[]]},{"id":"da81870.029d178","type":"function","z":"3f266560.cbf812","name":"","func":"const set_temp = global.get(\"temperature/set\") || 0;\nmsg.payload =set_temp ;\nreturn msg;","outputs":1,"noerr":0,"x":840,"y":40,"wires":[["6d974900.2db948"]]},{"id":"89f1131a.a7e948","type":"inject","z":"3f266560.cbf812","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":680,"y":40,"wires":[["da81870.029d178"]]},{"id":"6d974900.2db948","type":"debug","z":"3f266560.cbf812","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":1010,"y":40,"wires":[]},{"id":"57bf3d6a.7bc434","type":"change","z":"3f266560.cbf812","name":"SetHumidity","rules":[{"t":"set","p":"humidity/set","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":450,"y":120,"wires":[[]]},{"id":"692f1390.fe8d1c","type":"change","z":"3f266560.cbf812","name":"SetTime","rules":[{"t":"set","p":"time/set","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":440,"y":160,"wires":[[]]},{"id":"4a9f93f6.bc89cc","type":"function","z":"3f266560.cbf812","name":"","func":"const set_temp = global.get(\"humidity/set\") || 0;\nmsg.payload =set_temp ;\nreturn msg;","outputs":1,"noerr":0,"x":840,"y":100,"wires":[["5e8aa681.bbd308"]]},{"id":"ac6c753a.19d448","type":"inject","z":"3f266560.cbf812","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":680,"y":100,"wires":[["4a9f93f6.bc89cc"]]},{"id":"5e8aa681.bbd308","type":"debug","z":"3f266560.cbf812","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":1010,"y":100,"wires":[]},{"id":"4beee67d.bd3e28","type":"function","z":"3f266560.cbf812","name":"","func":"const set_temp = global.get(\"time/set\") || 0;\nmsg.payload =set_temp ;\nreturn msg;","outputs":1,"noerr":0,"x":820,"y":160,"wires":[["a4dfdc3f.57b238"]]},{"id":"2df5430a.f6b0a4","type":"inject","z":"3f266560.cbf812","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":680,"y":160,"wires":[["4beee67d.bd3e28"]]},{"id":"a4dfdc3f.57b238","type":"debug","z":"3f266560.cbf812","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":1010,"y":160,"wires":[]},{"id":"f7f27ee7.48fb5","type":"function","z":"3f266560.cbf812","name":"Switching","func":"const set_temp = global.get(\"temperature/set\");\nconst set_hum = global.get(\"humidity/set\");\nconst set_time = global.get(\"time/set\");\nconst live_temp = global.get(\"temperature/live\");\nconst live_hum = global.get(\"humidity/live\");\nconst timer_status = global.get(\"active/time/reset\");\n//const timer_close = global.get(\"active/time/reset/close\");\n\nconst override = global.get(\"AutoManual_switch\") || 0;\n\nvar getSetTemp = Number(set_temp);\nvar getSetHum = Number(set_hum);\nvar getLiveTemp = Number(live_temp);\nvar getLiveHum = Number(live_hum);\n\nvar on = 0;\nvar off = 1;\n\nvar heater = 1;\nvar spray = 1;\nvar flapO = 1;\nvar falpC = 1;\n\n\nif (override != 1 && timer_status === \"open\") {\n if(getLiveTemp < getSetTemp && getLiveHum < getSetHum){\n \n heater = { payload:on, topic:\"heater_on\" };\n spray = { payload:on, topic:\"spray_on\" };\n flapO = { payload:off, topic:\"flap_open_off\" };\n falpC = { payload:on, topic:\"flap_close_on\" };\n \n }\n else if(getLiveTemp < getSetTemp && getLiveHum > getSetHum){\n \n heater = { payload:on, topic:\"heater_on\" };\n spray = { payload:off, topic:\"spray_off\" };\n flapO = { payload:off, topic:\"flap_open_off\" };\n falpC = { payload:on, topic:\"flap_close_on\" };\n \n }\n else if(getLiveTemp > getSetTemp && getLiveHum < getSetHum){\n \n heater = { payload:off, topic:\"heater_off\" };\n spray = { payload:on, topic:\"spray_on\" };\n flapO = { payload:on, topic:\"flap_open_on\" };\n falpC = { payload:off, topic:\"flap_close_off\" };\n \n }\n else if(getLiveTemp > getSetTemp && getLiveHum > getSetHum){\n \n heater = { payload:off, topic:\"heater_off\" };\n spray = { payload:off, topic:\"spray_off\" };\n flapO = { payload:off, topic:\"flap_open_off\" };\n falpC = { payload:on, topic:\"flap_close_on\" };\n \n }\n\nreturn [heater, spray, flapO, falpC] ;\n}\nelse if(override != 1 && timer_status === \"close\"){\n heater = { payload:off, topic:\"heater_off\" };\n spray = { payload:off, topic:\"spray_off\" };\n flapO = { payload:off, topic:\"flap_open_off\" };\n falpC = { payload:off, topic:\"flap_close_on\" };\n return [heater, spray, flapO, falpC] ;\n }\n\n\n\n\n\n\n","outputs":4,"noerr":0,"x":280,"y":960,"wires":[["33c709e2.341b9e","584e0c40.bd2dfc"],["5a9e7f91.3d7ad8","7e1a8ad0.44c8c4"],["1dc49956.265d3f","3201237.c5c6adc"],["c1dc3e13.e7d47","1c28e14d.3fe257"]]},{"id":"33c709e2.341b9e","type":"debug","z":"3f266560.cbf812","name":"heater","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":490,"y":800,"wires":[]},{"id":"c1dc3e13.e7d47","type":"debug","z":"3f266560.cbf812","name":"flap_close","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":500,"y":1120,"wires":[]},{"id":"1dc49956.265d3f","type":"debug","z":"3f266560.cbf812","name":"flap_open","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":500,"y":1020,"wires":[]},{"id":"5a9e7f91.3d7ad8","type":"debug","z":"3f266560.cbf812","name":"spray","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":490,"y":920,"wires":[]},{"id":"5ef8c02c.24f9b","type":"mqtt in","z":"3f266560.cbf812","name":"","topic":"topic_temp","qos":"2","datatype":"auto","broker":"f63fceb2.278a7","x":1220,"y":40,"wires":[["3c790a92.25ee56","e9fb1270.c29408"]]},{"id":"3c790a92.25ee56","type":"change","z":"3f266560.cbf812","name":"LiveTemperature","rules":[{"t":"set","p":"temperature/live","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1430,"y":40,"wires":[["df1fc87f.b04508"]]},{"id":"cbd73116.128188","type":"mqtt in","z":"3f266560.cbf812","name":"","topic":"topic_hum","qos":"2","datatype":"auto","broker":"f63fceb2.278a7","x":1220,"y":100,"wires":[["d62e0299.974cf","e9fb1270.c29408"]]},{"id":"d62e0299.974cf","type":"change","z":"3f266560.cbf812","name":"LiveHumidity","rules":[{"t":"set","p":"humidity/live","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1410,"y":100,"wires":[["92f51517.ec4c7"]]},{"id":"84369b2f.5699e","type":"inject","z":"3f266560.cbf812","name":"","topic":"","payload":"1","payloadType":"str","repeat":"1","crontab":"","once":true,"onceDelay":"1","x":70,"y":960,"wires":[["f7f27ee7.48fb5"]]},{"id":"6ca935a3.91c934","type":"mqtt out","z":"3f266560.cbf812","name":"","topic":"topic_temp","qos":"","retain":"","broker":"f8d6beaf.06bc","x":1470,"y":160,"wires":[]},{"id":"8032b99f.97705","type":"mqtt out","z":"3f266560.cbf812","name":"","topic":"topic_hum","qos":"","retain":"","broker":"f8d6beaf.06bc","x":1470,"y":220,"wires":[]},{"id":"584e0c40.bd2dfc","type":"change","z":"3f266560.cbf812","name":"HeaterState","rules":[{"t":"set","p":"heaterState","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":510,"y":760,"wires":[["73ef42d2.5157b4"]]},{"id":"7e1a8ad0.44c8c4","type":"change","z":"3f266560.cbf812","name":"SprayState","rules":[{"t":"set","p":"sprayState","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":510,"y":880,"wires":[["da276ecd.25245"]]},{"id":"3201237.c5c6adc","type":"change","z":"3f266560.cbf812","name":"FlapOpenState","rules":[{"t":"set","p":"flap_openState","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":520,"y":980,"wires":[["cd4c4a45.437ac"]]},{"id":"1c28e14d.3fe257","type":"change","z":"3f266560.cbf812","name":"FlapCloseState","rules":[{"t":"set","p":"flap_openState","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":520,"y":1080,"wires":[["4c6f7bc1.7b4cbc"]]},{"id":"16ddac42.bc6094","type":"function","z":"3f266560.cbf812","name":"","func":"const set_temp = global.get(\"heaterState\") || 0;\nmsg.payload =set_temp ;\nreturn msg;","outputs":1,"noerr":0,"x":280,"y":1180,"wires":[["a982b09d.72f658"]]},{"id":"9ee9d0da.904478","type":"inject","z":"3f266560.cbf812","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":110,"y":1180,"wires":[["16ddac42.bc6094"]]},{"id":"a982b09d.72f658","type":"debug","z":"3f266560.cbf812","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":470,"y":1180,"wires":[]},{"id":"604ca71a.347038","type":"gate","z":"3f266560.cbf812","name":"gate","controlTopic":"control","defaultState":"closed","openCmd":"open","closeCmd":"close","toggleCmd":"toggle","defaultCmd":"default","persist":false,"x":430,"y":520,"wires":[["956d6473.e0f898"]]},{"id":"6a94f355.75fe9c","type":"inject","z":"3f266560.cbf812","name":"input","topic":"","payload":"1","payloadType":"num","repeat":"1","crontab":"","once":false,"x":530,"y":360,"wires":[["604ca71a.347038"]]},{"id":"956d6473.e0f898","type":"counter","z":"3f266560.cbf812","name":"","init":"0","step":"1","lower":null,"upper":null,"mode":"increment","outputs":2,"x":578.499906539917,"y":519.4167966842651,"wires":[["681f7a2f.eb305c","ed94fbaa.ac8378","66f6bc99.452614"],[]]},{"id":"3db96076.b69ed","type":"inject","z":"3f266560.cbf812","name":"Start","topic":"control","payload":"open","payloadType":"str","repeat":"","crontab":"","once":false,"x":531.2500057220459,"y":398.74999952316284,"wires":[["604ca71a.347038"]]},{"id":"eb583b20.ac2e88","type":"inject","z":"3f266560.cbf812","name":"Stop","topic":"control","payload":"close","payloadType":"str","repeat":"","crontab":"","once":false,"x":533.000057220459,"y":441.50009870529175,"wires":[["604ca71a.347038"]]},{"id":"681f7a2f.eb305c","type":"debug","z":"3f266560.cbf812","name":"Current Payload","active":false,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":760,"y":580,"wires":[]},{"id":"eb6c8e52.afbd78","type":"inject","z":"3f266560.cbf812","name":"Reset","topic":"","payload":"0","payloadType":"str","repeat":"","crontab":"","once":false,"x":70,"y":380,"wires":[["69b02f34.e2258"]]},{"id":"69b02f34.e2258","type":"function","z":"3f266560.cbf812","name":"Reset Counter","func":"msg.reset=msg.payload\nreturn msg;","outputs":1,"noerr":0,"x":260,"y":380,"wires":[["956d6473.e0f898"]]},{"id":"2a4a24ff.11264c","type":"mqtt in","z":"3f266560.cbf812","name":"","topic":"time/set","qos":"2","broker":"667f47ab.1f09d8","x":46.24998092651367,"y":551.2499647140503,"wires":[["9b92f29c.4fdb8"]]},{"id":"9b92f29c.4fdb8","type":"function","z":"3f266560.cbf812","name":"compareTime","func":"const set_time = global.get(\"time/set\");\nconst run_time = global.get(\"Run_Time\");\n//var x = flow.get('Set_Time');\n//var y = flow.get('Run_Time');\nvar Set_Time = Number(set_time); //convert to a number\nvar Run_Time = Number(run_time); //convert to a number\n \n var z = Set_Time;//*60*60;\n if(z > Run_Time){\n msg.payload = \"open\";\n msg.topic = \"control\"\n return [msg, null];\n }\n else\n {\n msg.payload = \"close\";\n msg.topic = \"control\"\n return [null, msg];\n}\n//return msg;Set_Time","outputs":2,"noerr":0,"x":207.4999885559082,"y":524.9999990463257,"wires":[["604ca71a.347038","3906f160.af39a6"],["604ca71a.347038","830bb5f8.76541"]]},{"id":"ed94fbaa.ac8378","type":"function","z":"3f266560.cbf812","name":"setPayload","func":"var Run_Time= {\"payload\":msg.payload};\nreturn Run_Time;","outputs":1,"noerr":0,"x":752.5000076293945,"y":513.7499980926514,"wires":[["84798e9a.c227b"]]},{"id":"a40acdb8.7ef2","type":"debug","z":"3f266560.cbf812","name":"Current Payload","active":false,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":1140,"y":520,"wires":[]},{"id":"1f43ea25.71d85e","type":"function","z":"3f266560.cbf812","name":"SetTime","func":"flow.set('Run_Time',msg.payload);\nreturn msg;","outputs":1,"noerr":0,"x":1440,"y":820,"wires":[[]]},{"id":"d54b198b.7067e8","type":"inject","z":"3f266560.cbf812","name":"input","topic":"","payload":"1","payloadType":"num","repeat":"1","crontab":"","once":false,"x":52.67855453491211,"y":501.78565883636475,"wires":[["9b92f29c.4fdb8"]]},{"id":"c6bfd525.f0ba08","type":"debug","z":"3f266560.cbf812","name":"Current Payload","active":false,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":260,"y":420,"wires":[]},{"id":"bdba9609.5c467","type":"debug","z":"3f266560.cbf812","name":"Current Payload","active":false,"console":false,"complete":"payload","x":440,"y":580,"wires":[]},{"id":"66f6bc99.452614","type":"function","z":"3f266560.cbf812","name":"[s] to [hh:mm:ss]","func":"// Message from preceeding node is in seconds - should be less than 24 hours (86400 seconds).\nvar time = (new Date(msg.payload * 1000)).toUTCString().match(/(\\d\\d:\\d\\d:\\d\\d)/)[0];\n// Pass on the string to the next node, what ever that may be. (groov Data Store for example).\nmsg.payload = time;\nreturn msg;","outputs":1,"noerr":0,"x":752.8571586608887,"y":460.8927869796753,"wires":[["a2821e5c.4723c"]]},{"id":"a2821e5c.4723c","type":"ui_text","z":"3f266560.cbf812","group":"e45b5db9.36a54","order":2,"width":0,"height":0,"name":"","label":"Running Time","format":"{{msg.payload}}","layout":"row-spread","x":966.7144203186035,"y":460.2579388618469,"wires":[]},{"id":"84798e9a.c227b","type":"change","z":"3f266560.cbf812","name":"SetRun_Time","rules":[{"t":"set","p":"Run_Time","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":940,"y":520,"wires":[["a40acdb8.7ef2"]]},{"id":"c6fb609f.3be68","type":"function","z":"3f266560.cbf812","name":"setState_1","func":"//const set_time = global.get(\"time/set\");\n//const run_time = global.get(\"Run_Time\");\n//var x = flow.get('Set_Time');\n//var y = flow.get('Run_Time');\n//var Set_Time = Number(set_time); //convert to a number\n//var Run_Time = Number(run_time); //convert to a number\n\nvar trigger = msg.payload;\n \n//var z = Set_Time;//*60*60;\n\nif(trigger === \"close\"){\n global.set(\"heaterState\", \"1\");\n global.set(\"sprayState\", \"1\");\n global.set(\"fancwState\", \"1\");\n global.set(\"fanccwState\", \"1\");\n global.set(\"flap_openState\", \"1\");\n global.set(\"flap_closeState\", \"1\");\n}\n// else\n// {\n// msg.payload = \"close\";\n// msg.topic = \"control\"\n// return [null, msg];\n//}\n//return msg;Set_Time\n\n","outputs":1,"noerr":0,"x":410,"y":660,"wires":[[]]},{"id":"830bb5f8.76541","type":"change","z":"3f266560.cbf812","name":"SetTimeReset","rules":[{"t":"set","p":"active/time/reset","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":200,"y":600,"wires":[["bdba9609.5c467"]]},{"id":"6a58e6dd.47191","type":"function","z":"3f266560.cbf812","name":"","func":"const set_temp = global.get(\"active/time/reset\");\nmsg.payload =set_temp ;\nreturn msg;","outputs":1,"noerr":0,"x":920,"y":380,"wires":[["e2db8c7f.2bf788"]]},{"id":"e3fe3f71.95a8d8","type":"inject","z":"3f266560.cbf812","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":780,"y":380,"wires":[["6a58e6dd.47191"]]},{"id":"e2db8c7f.2bf788","type":"debug","z":"3f266560.cbf812","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":1110,"y":380,"wires":[]},{"id":"3906f160.af39a6","type":"change","z":"3f266560.cbf812","name":"SetTimeReset","rules":[{"t":"set","p":"active/time/reset","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":200,"y":460,"wires":[["c6bfd525.f0ba08"]]},{"id":"948d3c65.001a8","type":"function","z":"3f266560.cbf812","name":"","func":"const set_temp = global.get(\"active/time/reset\");\nmsg.payload =set_temp ;\nreturn msg;","outputs":1,"noerr":0,"x":840,"y":660,"wires":[["ccdb8966.232f48"]]},{"id":"8af364a1.f69c4","type":"inject","z":"3f266560.cbf812","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":670,"y":660,"wires":[["948d3c65.001a8"]]},{"id":"ccdb8966.232f48","type":"debug","z":"3f266560.cbf812","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":1030,"y":660,"wires":[]},{"id":"73ef42d2.5157b4","type":"ui_text","z":"3f266560.cbf812","group":"d392b557.00e6b","order":0,"width":0,"height":0,"name":"","label":"Heater","format":"{{msg.payload}}","layout":"row-spread","x":750,"y":780,"wires":[]},{"id":"da276ecd.25245","type":"ui_text","z":"3f266560.cbf812","group":"d392b557.00e6b","order":0,"width":0,"height":0,"name":"","label":"Spray","format":"{{msg.payload}}","layout":"row-spread","x":740,"y":900,"wires":[]},{"id":"cd4c4a45.437ac","type":"ui_text","z":"3f266560.cbf812","group":"d392b557.00e6b","order":0,"width":0,"height":0,"name":"","label":"Flap Open","format":"{{msg.payload}}","layout":"row-spread","x":760,"y":1000,"wires":[]},{"id":"4c6f7bc1.7b4cbc","type":"ui_text","z":"3f266560.cbf812","group":"d392b557.00e6b","order":0,"width":0,"height":0,"name":"","label":"Flap Close","format":"{{msg.payload}}","layout":"row-spread","x":740,"y":1100,"wires":[]},{"id":"21c1c499.e93c34","type":"ui_text","z":"3f266560.cbf812","group":"c3711ff9.3ee378","order":1,"width":0,"height":0,"name":"","label":"Set Temp","format":"{{msg.payload}}","layout":"row-spread","x":500,"y":220,"wires":[]},{"id":"b4e88eb4.50d2e8","type":"ui_text","z":"3f266560.cbf812","group":"c3711ff9.3ee378","order":2,"width":0,"height":0,"name":"","label":"Set Hum","format":"{{msg.payload}}","layout":"row-spread","x":500,"y":260,"wires":[]},{"id":"df1fc87f.b04508","type":"ui_text","z":"3f266560.cbf812","group":"c3711ff9.3ee378","order":3,"width":0,"height":0,"name":"","label":"Live Temp","format":"{{msg.payload}}","layout":"row-spread","x":1630,"y":40,"wires":[]},{"id":"92f51517.ec4c7","type":"ui_text","z":"3f266560.cbf812","group":"c3711ff9.3ee378","order":4,"width":0,"height":0,"name":"","label":"Live Hum","format":"{{msg.payload}}","layout":"row-spread","x":1620,"y":100,"wires":[]},{"id":"e9fb1270.c29408","type":"debug","z":"3f266560.cbf812","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":1450,"y":320,"wires":[]},{"id":"6ef4c368.950884","type":"inject","z":"3f266560.cbf812","name":"Hum","topic":"","payload":"60","payloadType":"str","repeat":"5","crontab":"","once":false,"onceDelay":0.1,"x":1230,"y":220,"wires":[[]]},{"id":"3fc83dec.1dfd2a","type":"inject","z":"3f266560.cbf812","name":"Temp","topic":"","payload":"30","payloadType":"str","repeat":"5","crontab":"","once":false,"onceDelay":0.1,"x":1230,"y":160,"wires":[[]]},{"id":"1f9e4544.2ce6f3","type":"mqtt in","z":"3f266560.cbf812","name":"","topic":"topic_temp_1","qos":"2","datatype":"auto","broker":"f63fceb2.278a7","x":1390,"y":460,"wires":[["47631957.ed62f8"]]},{"id":"47631957.ed62f8","type":"change","z":"3f266560.cbf812","name":"LiveTemperature","rules":[{"t":"set","p":"temperature_1/live","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1590,"y":460,"wires":[["2985a625.d5337a"]]},{"id":"c6d31f76.fb464","type":"mqtt in","z":"3f266560.cbf812","name":"","topic":"topic_hum_1","qos":"2","datatype":"auto","broker":"f63fceb2.278a7","x":1390,"y":520,"wires":[["32f4a9e1.48e8fe"]]},{"id":"32f4a9e1.48e8fe","type":"change","z":"3f266560.cbf812","name":"LiveHumidity","rules":[{"t":"set","p":"humidity_1/live","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1570,"y":520,"wires":[["c51b8878.7462b8"]]},{"id":"2985a625.d5337a","type":"ui_text","z":"3f266560.cbf812","group":"c3711ff9.3ee378","order":5,"width":0,"height":0,"name":"","label":"Live Temp 1","format":"{{msg.payload}}","layout":"row-spread","x":1790,"y":460,"wires":[]},{"id":"c51b8878.7462b8","type":"ui_text","z":"3f266560.cbf812","group":"c3711ff9.3ee378","order":7,"width":0,"height":0,"name":"","label":"Live Hum 1","format":"{{msg.payload}}","layout":"row-spread","x":1790,"y":520,"wires":[]},{"id":"47708ffd.058088","type":"mqtt in","z":"3f266560.cbf812","name":"","topic":"topic_temp_2","qos":"2","datatype":"auto","broker":"f63fceb2.278a7","x":1390,"y":580,"wires":[["59e1394a.bc3bc"]]},{"id":"59e1394a.bc3bc","type":"change","z":"3f266560.cbf812","name":"LiveTemperature","rules":[{"t":"set","p":"temperature_2/live","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1590,"y":580,"wires":[["3acf5473.d07c6c"]]},{"id":"d29bc12.d9eac4","type":"mqtt in","z":"3f266560.cbf812","name":"","topic":"topic_hum_2","qos":"2","datatype":"auto","broker":"f63fceb2.278a7","x":1390,"y":640,"wires":[["2f220c9a.f1fb3c"]]},{"id":"2f220c9a.f1fb3c","type":"change","z":"3f266560.cbf812","name":"LiveHumidity","rules":[{"t":"set","p":"humidity_2/live","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1570,"y":640,"wires":[["cd3b033f.07c298"]]},{"id":"3acf5473.d07c6c","type":"ui_text","z":"3f266560.cbf812","group":"c3711ff9.3ee378","order":6,"width":0,"height":0,"name":"","label":"Live Temp 2","format":"{{msg.payload}}","layout":"row-spread","x":1790,"y":580,"wires":[]},{"id":"cd3b033f.07c298","type":"ui_text","z":"3f266560.cbf812","group":"c3711ff9.3ee378","order":8,"width":0,"height":0,"name":"","label":"Live Hum 2","format":"{{msg.payload}}","layout":"row-spread","x":1790,"y":640,"wires":[]},{"id":"7d209806.b15e18","type":"function","z":"ed72f8b2.cea9c8","name":"","func":"const override = global.get(\"AutoManual_switch\") || 0;\nmsg.payload =override ;\nreturn msg;","outputs":1,"noerr":0,"x":350,"y":360,"wires":[["550bce51.99725"]]},{"id":"5c57ff.f6d9d8","type":"inject","z":"ed72f8b2.cea9c8","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":180,"y":360,"wires":[["7d209806.b15e18"]]},{"id":"550bce51.99725","type":"debug","z":"ed72f8b2.cea9c8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":540,"y":360,"wires":[]},{"id":"2c132af3.5d2096","type":"change","z":"ed72f8b2.cea9c8","name":"","rules":[{"t":"change","p":"payload","pt":"msg","from":"auto","fromt":"str","to":"Auto","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"manual","fromt":"str","to":"Manual","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":770,"y":40,"wires":[["8d443604.948fc8","f3289c3c.36231"]]},{"id":"1f6cd2cd.c8a8fd","type":"change","z":"ed72f8b2.cea9c8","name":"Auto/Manual var","rules":[{"t":"set","p":"AutoManual_switch","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":970,"y":80,"wires":[[]]},{"id":"90384946.ff1938","type":"change","z":"ed72f8b2.cea9c8","name":"","rules":[{"t":"change","p":"payload","pt":"msg","from":"manual","fromt":"str","to":"1","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":790,"y":220,"wires":[["ec1918d6.05cf48"]]},{"id":"8d443604.948fc8","type":"ui_text","z":"ed72f8b2.cea9c8","group":"2c8ed61a.6d4a0a","order":2,"width":"0","height":"0","name":"manualText","label":"Mode","format":"{{msg.payload}}","layout":"row-spread","x":960,"y":40,"wires":[]},{"id":"a40822f.6fa75e","type":"debug","z":"ed72f8b2.cea9c8","name":"Output to GPIO","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":770,"y":280,"wires":[]},{"id":"de0e54b2.3737d8","type":"function","z":"ed72f8b2.cea9c8","name":"turn on override","func":"const override = global.get(\"AutoManual_switch\") || 0;\nif(override === 0){\n msg.payload = \"manual\";\n return msg;\n} else {\n return null;\n}","outputs":1,"noerr":0,"x":770,"y":140,"wires":[["2c132af3.5d2096","3d545d07.441222"]]},{"id":"900f32eb.98135","type":"switch","z":"ed72f8b2.cea9c8","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"auto","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":500,"y":160,"wires":[["2c132af3.5d2096","553c1bfd.f7b624","520da9a8.69db98"],["de0e54b2.3737d8","90384946.ff1938","a40822f.6fa75e"]]},{"id":"553c1bfd.f7b624","type":"change","z":"ed72f8b2.cea9c8","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"0","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":770,"y":80,"wires":[["1f6cd2cd.c8a8fd"]]},{"id":"d4ec0623.e9af68","type":"inject","z":"ed72f8b2.cea9c8","name":"","topic":"","payload":"auto","payloadType":"str","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":160,"y":160,"wires":[["3b9505e0.7bdd9a"]]},{"id":"520da9a8.69db98","type":"debug","z":"ed72f8b2.cea9c8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":500,"y":60,"wires":[]},{"id":"ec1918d6.05cf48","type":"debug","z":"ed72f8b2.cea9c8","name":"Output to GPIO","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":1050,"y":320,"wires":[]},{"id":"3d545d07.441222","type":"change","z":"ed72f8b2.cea9c8","name":"","rules":[{"t":"change","p":"payload","pt":"msg","from":"manual","fromt":"str","to":"1","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":990,"y":160,"wires":[["1f6cd2cd.c8a8fd","5205ff07.3f9ef"]]},{"id":"5205ff07.3f9ef","type":"debug","z":"ed72f8b2.cea9c8","name":"Output to GPIO","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":1230,"y":160,"wires":[]},{"id":"56b52474.72ae6c","type":"ui_switch","z":"ed72f8b2.cea9c8","name":"","label":"Heater","tooltip":"","group":"2c8ed61a.6d4a0a","order":3,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"heater","style":"","onvalue":"0","onvalueType":"str","onicon":"","oncolor":"","offvalue":"1","offvalueType":"str","officon":"","offcolor":"","x":360,"y":580,"wires":[["adac13dc.99e08","153ad023.fed76"]]},{"id":"153ad023.fed76","type":"function","z":"ed72f8b2.cea9c8","name":"","func":"const Temp_topic = msg.topic;\nconst Temp_payload = msg.payload;\nconst override = global.get(\"AutoManual_switch\") || 0;\nconst fanstate = global.get(\"FanState\");\nif (override !== 0) {\n if (Temp_topic === \"heater\" && Temp_payload === \"0\") {\n msg.payload = 0;\n global.set(\"heaterState\", msg.payload);\n return msg;\n } else if(Temp_topic === \"heater\" && Temp_payload === \"1\") {\n msg.payload = 1;\n global.set(\"heaterState\", msg.payload);\n return msg;\n } else if(Temp_topic === \"spray\" && Temp_payload === \"0\") {\n msg.payload = 0;\n global.set(\"sprayState\", msg.payload);\n return msg;\n } else if(Temp_topic === \"spray\" && Temp_payload === \"1\") {\n msg.payload = 1;\n global.set(\"sprayState\", msg.payload);\n return msg;\n } else if(Temp_topic === \"fancw\" && Temp_payload === \"0\") {\n msg.payload = 0;\n global.set(\"fancwState\", msg.payload);\n return msg;\n } else if(Temp_topic === \"fancw\" && Temp_payload === \"1\") {\n msg.payload = 1;\n global.set(\"fancwState\", msg.payload);\n return msg;\n } else if(Temp_topic === \"fanccw\" && Temp_payload === \"0\") {\n msg.payload = 0;\n global.set(\"fanccwState\", msg.payload);\n return msg; \n } else if(Temp_topic === \"fanccw\" && Temp_payload === \"1\") {\n msg.payload = 1;\n global.set(\"fanccwState\", msg.payload);\n return msg; \n } else if(Temp_topic === \"flap/open\" && Temp_payload === \"0\") {\n msg.payload = 0;\n global.set(\"flap_openState\", msg.payload);\n return msg;\n } else if(Temp_topic === \"flap/open\" && Temp_payload === \"1\") {\n msg.payload = 1;\n global.set(\"flap_openState\", msg.payload);\n return msg;\n } else if(Temp_topic === \"flap/close\" && Temp_payload === \"0\") {\n msg.payload = 0;\n global.set(\"flap_closeState\", msg.payload);\n return msg;\n } else if(Temp_topic === \"flap/close\" && Temp_payload === \"1\") {\n msg.payload = 1;\n global.set(\"flap_closeState\", msg.payload);\n return msg;\n } else {\n return null;\n }\n}\n\n","outputs":1,"noerr":0,"x":580,"y":580,"wires":[["eda356d.8a7baa8"]]},{"id":"adac13dc.99e08","type":"debug","z":"ed72f8b2.cea9c8","name":"","active":false,"tosidebar":true,"console":false,"tostatus":true,"complete":"true","targetType":"full","x":440,"y":500,"wires":[]},{"id":"eda356d.8a7baa8","type":"debug","z":"ed72f8b2.cea9c8","name":"","active":false,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":770,"y":580,"wires":[]},{"id":"25045f0d.bf4ba","type":"ui_switch","z":"ed72f8b2.cea9c8","name":"","label":"Spray","tooltip":"","group":"2c8ed61a.6d4a0a","order":4,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"spray","style":"","onvalue":"0","onvalueType":"str","onicon":"","oncolor":"","offvalue":"1","offvalueType":"str","officon":"","offcolor":"","x":360,"y":660,"wires":[["153ad023.fed76"]]},{"id":"a3c71710.8f0a08","type":"ui_switch","z":"ed72f8b2.cea9c8","name":"","label":"Flap_open","tooltip":"","group":"2c8ed61a.6d4a0a","order":6,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"flap/open","style":"","onvalue":"0","onvalueType":"str","onicon":"","oncolor":"","offvalue":"1","offvalueType":"str","officon":"","offcolor":"","x":380,"y":840,"wires":[["153ad023.fed76"]]},{"id":"a00ffc4d.f9de3","type":"ui_switch","z":"ed72f8b2.cea9c8","name":"","label":"Flap_close","tooltip":"","group":"2c8ed61a.6d4a0a","order":5,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"flap/close","style":"","onvalue":"0","onvalueType":"str","onicon":"","oncolor":"","offvalue":"1","offvalueType":"str","officon":"","offcolor":"","x":380,"y":740,"wires":[["153ad023.fed76"]]},{"id":"734baee1.933d3","type":"inject","z":"ed72f8b2.cea9c8","name":"","topic":"","payload":"1","payloadType":"str","repeat":"","crontab":"","once":true,"onceDelay":"1","x":180,"y":580,"wires":[["56b52474.72ae6c","25045f0d.bf4ba","a3c71710.8f0a08","a00ffc4d.f9de3","4a0cf933.477748"]]},{"id":"4a0cf933.477748","type":"debug","z":"ed72f8b2.cea9c8","name":"","active":false,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":260,"y":500,"wires":[]},{"id":"650b8ab9.347824","type":"function","z":"ed72f8b2.cea9c8","name":"","func":"const heater = global.get(\"heaterState\") || 0;\nmsg.payload = heater ;\nreturn msg;","outputs":1,"noerr":0,"x":350,"y":980,"wires":[["765eaafc.278f74"]]},{"id":"6e9bd283.cad14c","type":"inject","z":"ed72f8b2.cea9c8","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":180,"y":980,"wires":[["650b8ab9.347824"]]},{"id":"765eaafc.278f74","type":"debug","z":"ed72f8b2.cea9c8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":540,"y":980,"wires":[]},{"id":"85a7213b.3f035","type":"function","z":"ed72f8b2.cea9c8","name":"Heater","func":"const heater = global.get(\"heaterState\");\nvar heaterS = heater.toString();\nmsg.payload =heaterS;\nreturn msg;","outputs":1,"noerr":0,"x":180,"y":640,"wires":[["56b52474.72ae6c"]]},{"id":"607d7327.a884fc","type":"inject","z":"ed72f8b2.cea9c8","name":"","topic":"","payload":"","payloadType":"str","repeat":"1","crontab":"","once":false,"onceDelay":0.1,"x":120,"y":680,"wires":[["85a7213b.3f035","b8dd60ba.55a34","f7e42a5e.90c748","6a0ac94.2ce2f38"]]},{"id":"b8dd60ba.55a34","type":"function","z":"ed72f8b2.cea9c8","name":"Spray","func":"const spray = global.get(\"sprayState\");\nvar sprayS = spray.toString();\nmsg.payload =sprayS ;\nreturn msg;","outputs":1,"noerr":0,"x":160,"y":740,"wires":[["25045f0d.bf4ba"]]},{"id":"f7e42a5e.90c748","type":"function","z":"ed72f8b2.cea9c8","name":"Flap Close","func":"const flapC = global.get(\"flap_closeState\");\nvar flapCS = flapC.toString();\nmsg.payload =flapCS ;\nreturn msg;","outputs":1,"noerr":0,"x":180,"y":800,"wires":[["a00ffc4d.f9de3"]]},{"id":"6a0ac94.2ce2f38","type":"function","z":"ed72f8b2.cea9c8","name":"Flap Open","func":"const flapO = global.get(\"flap_openState\");\nvar flapOS = flapO.toString();\nmsg.payload =flapOS ;\nreturn msg;","outputs":1,"noerr":0,"x":180,"y":860,"wires":[["a3c71710.8f0a08"]]},{"id":"16fc54c7.8985fb","type":"mqtt in","z":"e661d7b9.d19188","name":"","topic":"topic_temp","qos":"2","datatype":"auto","broker":"3ed10064.8bc86","x":100,"y":100,"wires":[["1b99d1e5.4d095e","2bc13daa.a4ce8a"]]},{"id":"1c9c9098.808e2f","type":"change","z":"e661d7b9.d19188","name":"LiveTemperature","rules":[{"t":"set","p":"temperature/live","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":470,"y":100,"wires":[[]]},{"id":"5b031ea3.6cbc6","type":"mqtt in","z":"e661d7b9.d19188","name":"","topic":"topic_hum","qos":"2","datatype":"auto","broker":"3ed10064.8bc86","x":140,"y":1020,"wires":[["82f57f8b.52af4","782a35e5.20fe9c","f2115c26.5733f","30a17aa1.7eb306","342f71b3.00f6e6","38d1c497.44f6b4"]]},{"id":"82f57f8b.52af4","type":"change","z":"e661d7b9.d19188","name":"LiveHumidity","rules":[{"t":"set","p":"humidity/live","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":430,"y":1020,"wires":[[]]},{"id":"7caa534b.3c131c","type":"mqtt out","z":"e661d7b9.d19188","name":"","topic":"topic_temp","qos":"","retain":"","broker":"d704bfab.90376","x":1630,"y":400,"wires":[]},{"id":"4089697e.6beba8","type":"mqtt out","z":"e661d7b9.d19188","name":"","topic":"topic_hum","qos":"","retain":"","broker":"d704bfab.90376","x":1630,"y":800,"wires":[]},{"id":"3316b8c.d14e148","type":"trigger","z":"e661d7b9.d19188","op1":"connected","op2":"not connected","op1type":"str","op2type":"str","duration":"30","extend":true,"units":"s","reset":"","bytopic":"all","name":"","x":290,"y":180,"wires":[["ddc4ae41.b0eda","f045385d.70e078"]]},{"id":"ddc4ae41.b0eda","type":"debug","z":"e661d7b9.d19188","name":"","active":false,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":510,"y":180,"wires":[]},{"id":"f045385d.70e078","type":"function","z":"e661d7b9.d19188","name":"","func":"var flag = msg.payload;\nif (flag === \"not connected\"){\n msg.payload = \"1\";\n return msg;\n}\n","outputs":1,"noerr":0,"x":460,"y":240,"wires":[["74749d45.9a4054","389e36d5.7f8fba","ccfbfd00.55e5d","69d29d3c.048734","9a14107e.e0318","bbdb1890.7ffd08","fc7a3905.d76818"]]},{"id":"26b69417.47734c","type":"inject","z":"e661d7b9.d19188","name":"","topic":"","payload":"not connected","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":200,"y":260,"wires":[["f045385d.70e078"]]},{"id":"74749d45.9a4054","type":"debug","z":"e661d7b9.d19188","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":650,"y":240,"wires":[]},{"id":"389e36d5.7f8fba","type":"change","z":"e661d7b9.d19188","name":"HeaterState","rules":[{"t":"set","p":"heaterState","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":630,"y":300,"wires":[[]]},{"id":"ccfbfd00.55e5d","type":"change","z":"e661d7b9.d19188","name":"SprayState","rules":[{"t":"set","p":"sprayState","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":630,"y":340,"wires":[[]]},{"id":"69d29d3c.048734","type":"change","z":"e661d7b9.d19188","name":"FlapOpenState","rules":[{"t":"set","p":"flap_openState","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":640,"y":380,"wires":[[]]},{"id":"9a14107e.e0318","type":"change","z":"e661d7b9.d19188","name":"FlapCloseState","rules":[{"t":"set","p":"flap_closeState","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":640,"y":420,"wires":[[]]},{"id":"bbdb1890.7ffd08","type":"change","z":"e661d7b9.d19188","name":"Auto/Manual var","rules":[{"t":"set","p":"AutoManual_switch","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":640,"y":460,"wires":[[]]},{"id":"31bdfc21.b40a04","type":"ui_text","z":"e661d7b9.d19188","group":"ce8a762f.5f9e78","order":1,"width":0,"height":0,"name":"","label":"Temperature","format":"{{msg.payload}}","layout":"row-spread","x":470,"y":60,"wires":[]},{"id":"782a35e5.20fe9c","type":"ui_text","z":"e661d7b9.d19188","group":"a49581bc.969ee","order":1,"width":0,"height":0,"name":"","label":"Humidity","format":"{{msg.payload}}","layout":"row-spread","x":420,"y":960,"wires":[]},{"id":"3b9505e0.7bdd9a","type":"ui_dropdown","z":"ed72f8b2.cea9c8","name":"","label":"","tooltip":"","place":"Select option","group":"2c8ed61a.6d4a0a","order":1,"width":0,"height":0,"passthru":true,"options":[{"label":"MANUAL","value":"manual","type":"str"},{"label":"AUTO","value":"auto","type":"str"}],"payload":"","topic":"","x":340,"y":160,"wires":[["900f32eb.98135"]]},{"id":"cd20e435.2545b8","type":"debug","z":"e661d7b9.d19188","name":"","active":false,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":270,"y":40,"wires":[]},{"id":"f2115c26.5733f","type":"debug","z":"e661d7b9.d19188","name":"","active":false,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":290,"y":900,"wires":[]},{"id":"c2ebaa31.fd4878","type":"mqtt in","z":"e661d7b9.d19188","name":"","topic":"topic_temp_1","qos":"2","datatype":"auto","broker":"f63fceb2.278a7","x":930,"y":520,"wires":[["d2d1e0ba.9e0a9"]]},{"id":"cff3d0f6.ccc55","type":"mqtt in","z":"e661d7b9.d19188","name":"","topic":"topic_hum_1","qos":"2","datatype":"auto","broker":"f63fceb2.278a7","x":930,"y":580,"wires":[["c9b17b35.940438"]]},{"id":"6b2a04a4.0e4fbc","type":"mqtt in","z":"e661d7b9.d19188","name":"","topic":"topic_temp_2","qos":"2","datatype":"auto","broker":"f63fceb2.278a7","x":930,"y":640,"wires":[["7c2dcecf.1e83b"]]},{"id":"9504921b.1ff9a","type":"mqtt in","z":"e661d7b9.d19188","name":"","topic":"topic_hum_2","qos":"2","datatype":"auto","broker":"f63fceb2.278a7","x":930,"y":700,"wires":[["945a5e43.f9087"]]},{"id":"14ea4a6b.ec5476","type":"debug","z":"e661d7b9.d19188","name":"","active":false,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":1510,"y":520,"wires":[]},{"id":"aae3857d.dc0b98","type":"debug","z":"e661d7b9.d19188","name":"","active":false,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":1510,"y":700,"wires":[]},{"id":"3424e858.0cc3e8","type":"mqtt out","z":"ed72f8b2.cea9c8","name":"","topic":"reset","qos":"","retain":"","broker":"4aee772d.de27a8","x":1370,"y":60,"wires":[]},{"id":"f3289c3c.36231","type":"change","z":"ed72f8b2.cea9c8","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"1","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1180,"y":60,"wires":[["3424e858.0cc3e8"]]},{"id":"2136b3a5.85b88c","type":"mqtt in","z":"ed72f8b2.cea9c8","name":"","topic":"reset","qos":"2","datatype":"auto","broker":"4aee772d.de27a8","x":70,"y":500,"wires":[["56b52474.72ae6c","25045f0d.bf4ba","a00ffc4d.f9de3","a3c71710.8f0a08"]]},{"id":"ae73635d.ce7a4","type":"function","z":"e661d7b9.d19188","name":"","func":"const live_temp_1 = global.get(\"temperature_1/live\");\nconst live_temp_2 = global.get(\"temperature_2/live\");\n\n\n\nvar getSetTemp1 = Number(live_temp_1);\nvar getSetTemp2 = Number(live_temp_2);\n\n\nvar avTemp = (getSetTemp1 + getSetTemp2)/2;\n\nmsg.payload = avTemp;\n\nreturn msg;","outputs":1,"noerr":0,"x":1350,"y":560,"wires":[["14ea4a6b.ec5476","1aabaee5.88c899"]]},{"id":"d2d1e0ba.9e0a9","type":"change","z":"e661d7b9.d19188","name":"LiveTemperature","rules":[{"t":"set","p":"temperature_1/live","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1170,"y":520,"wires":[["ae73635d.ce7a4","b85d0a87.d8098"]]},{"id":"c9b17b35.940438","type":"change","z":"e661d7b9.d19188","name":"LiveHumidity","rules":[{"t":"set","p":"humidity_1/live","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1150,"y":580,"wires":[["54f93113.bb41","1e4515e6.16c862"]]},{"id":"7c2dcecf.1e83b","type":"change","z":"e661d7b9.d19188","name":"LiveTemperature","rules":[{"t":"set","p":"temperature_2/live","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1170,"y":640,"wires":[["ae73635d.ce7a4","7c14ff8e.85f21"]]},{"id":"945a5e43.f9087","type":"change","z":"e661d7b9.d19188","name":"LiveHumidity","rules":[{"t":"set","p":"humidity_2/live","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1150,"y":700,"wires":[["54f93113.bb41","132b6e52.77128a"]]},{"id":"54f93113.bb41","type":"function","z":"e661d7b9.d19188","name":"","func":"const live_hum_1 = global.get(\"humidity_1/live\");\nconst live_hum_2 = global.get(\"humidity_2/live\");\n\n\n\nvar getSetHum1 = Number(live_hum_1);\nvar getSetHum2 = Number(live_hum_2);\n\n\nvar avHum = (getSetHum1 + getSetHum2)/2;\nmsg.payload = avHum;\nreturn msg;","outputs":1,"noerr":0,"x":1350,"y":680,"wires":[["aae3857d.dc0b98","174bae22.98755a"]]},{"id":"fc7a3905.d76818","type":"ui_toast","z":"e661d7b9.d19188","position":"top right","displayTime":"3","highlight":"","sendall":true,"outputs":0,"ok":"OK","cancel":"","raw":false,"topic":"","name":"","x":420,"y":340,"wires":[]},{"id":"313a77f9.6583e8","type":"function","z":"34243684.8b511a","name":"Time","func":"var Set_time= {\"payload\":msg.payload.SetTime};\n\n//flow.set('order_id', O_rderID);\n//msg.topic='Set_Temp'\n\nreturn Set_time;","outputs":1,"noerr":0,"x":310,"y":180,"wires":[["bf358768.679818"]]},{"id":"c555c93.111aa38","type":"comment","z":"34243684.8b511a","name":"User Input","info":"","x":320,"y":60,"wires":[]},{"id":"41d24efa.3923f","type":"ui_form","z":"34243684.8b511a","name":"","label":"","group":"b910ffa2.541dd","order":2,"width":0,"height":0,"options":[{"label":"Temperature","value":"SetTemperature","type":"text","required":true,"rows":null},{"label":"Humidity","value":"SetHumidity","type":"text","required":true,"rows":null},{"label":"Time","value":"SetTime","type":"text","required":true,"rows":null}],"formValue":{"SetTemperature":"","SetHumidity":"","SetTime":""},"payload":"","submit":"Start","cancel":"Cancel","topic":"","x":110,"y":120,"wires":[["7d945060.a9356","301f7c19.82d9f4","313a77f9.6583e8","c4cf9112.c467b","c1b42df4.a18f7"]]},{"id":"7d945060.a9356","type":"function","z":"34243684.8b511a","name":"Temp","func":"var Set_temp= {\"payload\":msg.payload.SetTemperature};\n\n//flow.set('order_id', O_rderID);\n//msg.topic='Set_Temp'\n\nreturn Set_temp;","outputs":1,"noerr":0,"x":310,"y":100,"wires":[["ab2396c0.3ae038","2cad8487.56bc5c"]]},{"id":"301f7c19.82d9f4","type":"function","z":"34243684.8b511a","name":"Hum","func":"var Set_hum = {\"payload\":msg.payload.SetHumidity};\n\n//flow.set('order_id', O_rderID);\n//msg.topic='Set_Temp'\n\nreturn Set_hum;","outputs":1,"noerr":0,"x":310,"y":140,"wires":[["ba62f2.dc8ebd1"]]},{"id":"c4cf9112.c467b","type":"debug","z":"34243684.8b511a","name":"","active":false,"console":"false","complete":"false","x":330,"y":240,"wires":[]},{"id":"ab2396c0.3ae038","type":"debug","z":"34243684.8b511a","name":"","active":false,"console":"false","complete":"false","x":490,"y":60,"wires":[]},{"id":"2cad8487.56bc5c","type":"change","z":"34243684.8b511a","name":"SetTemperature","rules":[{"t":"set","p":"temperature/set","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":500,"y":100,"wires":[["dce2a0e7.3a0378"]]},{"id":"1447a928.7fa9f7","type":"function","z":"34243684.8b511a","name":"","func":"const set_temp = global.get(\"temperature/set\") || 0;\nmsg.payload =set_temp ;\nreturn msg;","outputs":1,"noerr":0,"x":880,"y":60,"wires":[["b9c86d9.1b24d9"]]},{"id":"73c87c96.d0d204","type":"inject","z":"34243684.8b511a","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":720,"y":60,"wires":[["1447a928.7fa9f7"]]},{"id":"b9c86d9.1b24d9","type":"debug","z":"34243684.8b511a","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":1050,"y":60,"wires":[]},{"id":"ba62f2.dc8ebd1","type":"change","z":"34243684.8b511a","name":"SetHumidity","rules":[{"t":"set","p":"humidity/set","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":490,"y":140,"wires":[["a6ddaf59.3e1a5"]]},{"id":"bf358768.679818","type":"change","z":"34243684.8b511a","name":"SetTime","rules":[{"t":"set","p":"time/set","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":480,"y":180,"wires":[["519fdde8.d80804"]]},{"id":"ee5f94a3.b1fe08","type":"function","z":"34243684.8b511a","name":"","func":"const set_temp = global.get(\"humidity/set\") || 0;\nmsg.payload =set_temp ;\nreturn msg;","outputs":1,"noerr":0,"x":880,"y":120,"wires":[["6de12337.be574c"]]},{"id":"1828d093.6daecf","type":"inject","z":"34243684.8b511a","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":720,"y":120,"wires":[["ee5f94a3.b1fe08"]]},{"id":"6de12337.be574c","type":"debug","z":"34243684.8b511a","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":1050,"y":120,"wires":[]},{"id":"5b0a4c5e.2bffb4","type":"function","z":"34243684.8b511a","name":"","func":"const set_temp = global.get(\"time/set\") || 0;\nmsg.payload =set_temp ;\nreturn msg;","outputs":1,"noerr":0,"x":860,"y":180,"wires":[["a015e351.ad853"]]},{"id":"53b966cb.506c18","type":"inject","z":"34243684.8b511a","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":720,"y":180,"wires":[["5b0a4c5e.2bffb4"]]},{"id":"a015e351.ad853","type":"debug","z":"34243684.8b511a","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":1050,"y":180,"wires":[]},{"id":"e21fc623.8454b8","type":"function","z":"34243684.8b511a","name":"Switching","func":"const set_temp = global.get(\"temperature/set\");\nconst set_hum = global.get(\"humidity/set\");\nconst set_time = global.get(\"time/set\");\nconst live_temp = global.get(\"temperature/live\");\nconst live_hum = global.get(\"humidity/live\");\nconst timer_status = global.get(\"active/time/reset\");\n//const timer_close = global.get(\"active/time/reset/close\");\n\nconst override = global.get(\"AutoManual_switch\") || 0;\n\nvar getSetTemp = Number(set_temp);\nvar getSetHum = Number(set_hum);\nvar getLiveTemp = Number(live_temp);\nvar getLiveHum = Number(live_hum);\n\n\nvar getSetTime = Number(set_time);\n\nvar tInterval = getSetTime / 4;\n\nvar getSetTempMax = getSetTemp + 5;\nvar getSetHumMax = getSetHum + 5;\nvar getLiveTempMax = getLiveTemp + 7;\nvar getLiveHumMax = getLiveHum + 10;\n\nvar on = 0;\nvar off = 1;\n\n\nvar heater = 1;\nvar spray = 1;\nvar flapO = 1;\nvar falpC = 1;\nvar modeO = 0;\n\n\nif (override != 1 && timer_status === \"open\") {\n \n //Mode 1\n if(getLiveTemp < getSetTemp && getLiveHum < getSetHum){\n \n heater = { payload:on, topic:\"heater_on\" };\n spray = { payload:on, topic:\"spray_on\" };\n flapO = { payload:off, topic:\"flap_open_off\" };\n falpC = { payload:on, topic:\"flap_close_on\" };\n modeO = { payload:1, topic:\"Mode_01\" };\n \n }\n \n //Mode 2\n else if(getLiveTemp < getSetTemp && (getLiveHum > getSetHum && getLiveHum < getSetHumMax)){\n \n heater = { payload:on, topic:\"heater_on\" };\n spray = { payload:off, topic:\"spray_off\" };\n flapO = { payload:off, topic:\"flap_open_off\" };\n falpC = { payload:on, topic:\"flap_close_on\" };\n modeO = { payload:2, topic:\"Mode_02\" };\n \n }\n \n //Mode 3\n else if(getLiveTemp >= getSetTemp && getLiveHum <= getSetHum){\n \n heater = { payload:off, topic:\"heater_off\" };\n spray = { payload:on, topic:\"spray_on\" };\n flapO = { payload:off, topic:\"flap_open_off\" };\n falpC = { payload:on, topic:\"flap_close_on\" };\n modeO = { payload:3, topic:\"Mode_03\" };\n \n }\n \n //Mode 4\n else if((getLiveHum > getSetHum && getLiveHum < getSetHumMax) && getLiveTemp > getSetTemp){\n \n //x >= min && x <= max\n \n heater = { payload:off, topic:\"heater_off\" };\n spray = { payload:off, topic:\"spray_off\" };\n flapO = { payload:off, topic:\"flap_open_off\" };\n falpC = { payload:on, topic:\"flap_open_on\" };\n modeO = { payload:4, topic:\"Mode_04\" };\n \n }\n \n //Mode 5\n else if(getLiveHum > getSetHumMax+2){\n\n heater = { payload:off, topic:\"heater_off\" };\n spray = { payload:off, topic:\"spray_off\" };\n flapO = { payload:on, topic:\"flap_open_on\" };\n falpC = { payload:off, topic:\"flap_close_off\" };\n modeO = { payload:5, topic:\"Mode_05\" };\n \n } \n //Mode 6\n// else {\n\n// heater = { payload:off, topic:\"heater_off\" };\n// spray = { payload:off, topic:\"spray_off\" };\n// flapO = { payload:off, topic:\"flap_open_on\" };\n// falpC = { payload:on, topic:\"flap_close_off\" };\n// modeO = { payload:6, topic:\"Mode_06\" };\n \n// }\n \n \nreturn [heater, spray, flapO, falpC, modeO] ;\n}\n\n//Mode 7\nelse if(override != 1 && timer_status === \"close\"){\n heater = { payload:off, topic:\"heater_off\" };\n spray = { payload:off, topic:\"spray_off\" };\n flapO = { payload:off, topic:\"flap_open_off\" };\n falpC = { payload:off, topic:\"flap_close_on\" };\n modeO = { payload:7, topic:\"Mode_07\" };\n \n return [heater, spray, flapO, falpC, modeO] ;\n }\n \n //Mode 8\nelse{\n heater = { payload:off, topic:\"heater_off\" };\n spray = { payload:off, topic:\"spray_off\" };\n flapO = { payload:off, topic:\"flap_open_off\" };\n falpC = { payload:off, topic:\"flap_close_on\" };\n modeO = { payload:8, topic:\"Mode_08\" };\n \n return [heater, spray, flapO, falpC, modeO] ;\n}\n\n\n\n\n\n","outputs":5,"noerr":0,"x":320,"y":980,"wires":[["14ddd8ae.9adbe7","c2db6aa0.c38bb8"],["3a8111c3.517d6e","fd3a792f.f31418"],["5949419e.d8d86","f7f7c790.359fd8"],["828dc2e9.1cc04","52e5d6b0.fdf4c8"],["f944d751.4c0da8"]]},{"id":"14ddd8ae.9adbe7","type":"debug","z":"34243684.8b511a","name":"heater","active":false,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":530,"y":820,"wires":[]},{"id":"828dc2e9.1cc04","type":"debug","z":"34243684.8b511a","name":"flap_close","active":false,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":540,"y":1140,"wires":[]},{"id":"5949419e.d8d86","type":"debug","z":"34243684.8b511a","name":"flap_open","active":false,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":540,"y":1040,"wires":[]},{"id":"3a8111c3.517d6e","type":"debug","z":"34243684.8b511a","name":"spray","active":false,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":530,"y":940,"wires":[]},{"id":"a8190197.faa74","type":"inject","z":"34243684.8b511a","name":"","topic":"","payload":"1","payloadType":"str","repeat":"1","crontab":"","once":true,"onceDelay":"1","x":110,"y":980,"wires":[["e21fc623.8454b8"]]},{"id":"c2db6aa0.c38bb8","type":"change","z":"34243684.8b511a","name":"HeaterState","rules":[{"t":"set","p":"heaterState","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":550,"y":780,"wires":[[]]},{"id":"fd3a792f.f31418","type":"change","z":"34243684.8b511a","name":"SprayState","rules":[{"t":"set","p":"sprayState","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":550,"y":900,"wires":[[]]},{"id":"f7f7c790.359fd8","type":"change","z":"34243684.8b511a","name":"FlapOpenState","rules":[{"t":"set","p":"flap_openState","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":560,"y":1000,"wires":[[]]},{"id":"52e5d6b0.fdf4c8","type":"change","z":"34243684.8b511a","name":"FlapCloseState","rules":[{"t":"set","p":"flap_closeState","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":560,"y":1100,"wires":[[]]},{"id":"28f9fe8b.5a7a82","type":"gate","z":"34243684.8b511a","name":"gate","controlTopic":"control","defaultState":"closed","openCmd":"open","closeCmd":"close","toggleCmd":"toggle","defaultCmd":"default","persist":false,"x":470,"y":540,"wires":[["25748c6c.7da3e4"]]},{"id":"385cf688.641c9a","type":"inject","z":"34243684.8b511a","name":"input","topic":"","payload":"1","payloadType":"num","repeat":"1","crontab":"","once":false,"x":570,"y":380,"wires":[["28f9fe8b.5a7a82"]]},{"id":"25748c6c.7da3e4","type":"counter","z":"34243684.8b511a","name":"","init":"0","step":"1","lower":null,"upper":null,"mode":"increment","outputs":2,"x":618.499906539917,"y":539.4167966842651,"wires":[["73774bd3.f205e4","4dbe08c.44f3ff8","7843866c.cdb708"],[]]},{"id":"b1f8c959.ef8188","type":"inject","z":"34243684.8b511a","name":"Start","topic":"control","payload":"open","payloadType":"str","repeat":"","crontab":"","once":false,"x":571.2500057220459,"y":418.74999952316284,"wires":[["28f9fe8b.5a7a82"]]},{"id":"2b3d7180.37bece","type":"inject","z":"34243684.8b511a","name":"Stop","topic":"control","payload":"close","payloadType":"str","repeat":"","crontab":"","once":false,"x":573.000057220459,"y":461.50009870529175,"wires":[["28f9fe8b.5a7a82"]]},{"id":"73774bd3.f205e4","type":"debug","z":"34243684.8b511a","name":"Current Payload","active":false,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":800,"y":600,"wires":[]},{"id":"48f2da22.28a684","type":"inject","z":"34243684.8b511a","name":"Reset","topic":"","payload":"0","payloadType":"str","repeat":"","crontab":"","once":false,"x":110,"y":400,"wires":[["c1b42df4.a18f7"]]},{"id":"c1b42df4.a18f7","type":"function","z":"34243684.8b511a","name":"Reset Counter","func":"msg.reset=msg.payload\nreturn msg;","outputs":1,"noerr":0,"x":300,"y":400,"wires":[["25748c6c.7da3e4"]]},{"id":"80cb0a13.9aa798","type":"function","z":"34243684.8b511a","name":"compareTime","func":"const set_time = global.get(\"time/set\");\nconst run_time = global.get(\"Run_Time\");\nconst overrideM = global.get(\"AutoManual_switch\");\n//var x = flow.get('Set_Time');\n//var y = flow.get('Run_Time');\n//(override != 1 && timer_status === \"open\")\nvar Set_Time = Number(set_time); //convert to a number\nvar Run_TimeN = Number(run_time); //convert to a number\n \n var z = Set_Time*60*60;\n if(overrideM !== 1 && z > Run_TimeN){\n msg.payload = \"open\";\n msg.topic = \"control\"\n return [msg, null];\n }\n else if (overrideM !== 1 && z < Run_TimeN)\n {\n msg.payload = \"close\";\n msg.topic = \"control\"\n return [null, msg];\n}\n//return msg;Set_Time","outputs":2,"noerr":0,"x":247.4999885559082,"y":544.9999990463257,"wires":[["28f9fe8b.5a7a82","f57693b0.a8432"],["28f9fe8b.5a7a82","4a70bd79.f31094"]]},{"id":"4dbe08c.44f3ff8","type":"function","z":"34243684.8b511a","name":"setPayload","func":"var Run_TimeSet= {\"payload\":msg.payload};\nreturn Run_TimeSet;","outputs":1,"noerr":0,"x":792.5000076293945,"y":533.7499980926514,"wires":[["e333331d.78394"]]},{"id":"b1636e6b.362a8","type":"debug","z":"34243684.8b511a","name":"Current Payload","active":false,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":1180,"y":540,"wires":[]},{"id":"ec615cb3.c6afe","type":"inject","z":"34243684.8b511a","name":"input","topic":"","payload":"1","payloadType":"num","repeat":"1","crontab":"","once":false,"x":92.67855453491211,"y":521.7856588363647,"wires":[["80cb0a13.9aa798"]]},{"id":"e33b217c.8f3f1","type":"debug","z":"34243684.8b511a","name":"Current Payload","active":false,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":300,"y":440,"wires":[]},{"id":"ad5a7d44.52b3b","type":"debug","z":"34243684.8b511a","name":"Current Payload","active":false,"console":false,"complete":"payload","x":480,"y":620,"wires":[]},{"id":"7843866c.cdb708","type":"function","z":"34243684.8b511a","name":"[s] to [hh:mm:ss]","func":"// Message from preceeding node is in seconds - should be less than 24 hours (86400 seconds).\nvar time = (new Date(msg.payload * 1000)).toUTCString().match(/(\\d\\d:\\d\\d:\\d\\d)/)[0];\n// Pass on the string to the next node, what ever that may be. (groov Data Store for example).\nmsg.payload = time;\nreturn msg;","outputs":1,"noerr":0,"x":792.8571586608887,"y":480.8927869796753,"wires":[["15dd3582.736b3a","35702cde.e4e11c"]]},{"id":"15dd3582.736b3a","type":"ui_text","z":"34243684.8b511a","group":"b910ffa2.541dd","order":2,"width":0,"height":0,"name":"","label":"Running Time","format":"{{msg.payload}}","layout":"row-spread","x":1006.7144203186035,"y":480.2579388618469,"wires":[]},{"id":"e333331d.78394","type":"change","z":"34243684.8b511a","name":"SetRun_Time","rules":[{"t":"set","p":"Run_Time","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":980,"y":540,"wires":[["b1636e6b.362a8"]]},{"id":"4a70bd79.f31094","type":"change","z":"34243684.8b511a","name":"SetTimeReset","rules":[{"t":"set","p":"active/time/reset","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":240,"y":620,"wires":[["ad5a7d44.52b3b"]]},{"id":"bff10e2d.a5b8e","type":"function","z":"34243684.8b511a","name":"","func":"const set_temp = global.get(\"active/time/reset\");\nmsg.payload =set_temp ;\nreturn msg;","outputs":1,"noerr":0,"x":960,"y":400,"wires":[["a7ee8b25.eaabf8"]]},{"id":"8ad6d2ff.235fb","type":"inject","z":"34243684.8b511a","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":820,"y":400,"wires":[["bff10e2d.a5b8e"]]},{"id":"a7ee8b25.eaabf8","type":"debug","z":"34243684.8b511a","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":1150,"y":400,"wires":[]},{"id":"f57693b0.a8432","type":"change","z":"34243684.8b511a","name":"SetTimeReset","rules":[{"t":"set","p":"active/time/reset","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":240,"y":480,"wires":[["e33b217c.8f3f1"]]},{"id":"de430b19.d832e8","type":"function","z":"34243684.8b511a","name":"","func":"const set_temp = global.get(\"AutoManual_switch\");\nmsg.payload =set_temp ;\nreturn msg;","outputs":1,"noerr":0,"x":880,"y":680,"wires":[["90ac20c0.7597d"]]},{"id":"f86e1b6e.eadb38","type":"inject","z":"34243684.8b511a","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":710,"y":680,"wires":[["de430b19.d832e8"]]},{"id":"90ac20c0.7597d","type":"debug","z":"34243684.8b511a","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":1070,"y":680,"wires":[]},{"id":"a49a6994.962d78","type":"ui_form","z":"bdd9cacd.0c9dd8","name":"","label":"Set Time","group":"9bc4db16.969488","order":2,"width":0,"height":0,"options":[{"label":"","value":"SetTime","type":"text","required":true,"rows":null}],"formValue":{"SetTime":""},"payload":"","submit":"Start","cancel":"Cancel","topic":"","x":100,"y":100,"wires":[["418719ad.358998","2cfddc9f.fa2da4"]]},{"id":"79fcb450.d0295c","type":"gate","z":"bdd9cacd.0c9dd8","name":"gate","controlTopic":"fancontrol_cw","defaultState":"closed","openCmd":"fanopen_cw","closeCmd":"fanclose_cw","toggleCmd":"toggle","defaultCmd":"default","persist":false,"x":490,"y":380,"wires":[["6672f6ce.e1a7c8"]]},{"id":"78aa4f4c.214df","type":"inject","z":"bdd9cacd.0c9dd8","name":"input","topic":"","payload":"1","payloadType":"num","repeat":"1","crontab":"","once":false,"x":590,"y":220,"wires":[["79fcb450.d0295c"]]},{"id":"6672f6ce.e1a7c8","type":"counter","z":"bdd9cacd.0c9dd8","name":"","init":"0","step":"1","lower":"","upper":"","mode":"increment","outputs":2,"x":638.499906539917,"y":379.41679668426514,"wires":[["a573a319.f7588","b0a6dcf5.57b7d","b06badf9.bf1a7"],[]]},{"id":"a9f2656e.abb4c8","type":"inject","z":"bdd9cacd.0c9dd8","name":"Start","topic":"control","payload":"open","payloadType":"str","repeat":"","crontab":"","once":false,"x":591.2500057220459,"y":258.74999952316284,"wires":[["79fcb450.d0295c"]]},{"id":"804fb4a0.1e31e8","type":"inject","z":"bdd9cacd.0c9dd8","name":"Stop","topic":"control","payload":"close","payloadType":"str","repeat":"","crontab":"","once":false,"x":593.000057220459,"y":301.50009870529175,"wires":[["79fcb450.d0295c"]]},{"id":"a573a319.f7588","type":"debug","z":"bdd9cacd.0c9dd8","name":"Current Payload","active":false,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":820,"y":440,"wires":[]},{"id":"c61ddbc6.7da008","type":"inject","z":"bdd9cacd.0c9dd8","name":"Reset","topic":"","payload":"0","payloadType":"str","repeat":"","crontab":"","once":false,"x":130,"y":240,"wires":[["2cfddc9f.fa2da4"]]},{"id":"2cfddc9f.fa2da4","type":"function","z":"bdd9cacd.0c9dd8","name":"Reset Counter","func":"msg.reset=msg.payload\nreturn msg;","outputs":1,"noerr":0,"x":320,"y":240,"wires":[["6672f6ce.e1a7c8"]]},{"id":"e6df4a18.979128","type":"function","z":"bdd9cacd.0c9dd8","name":"compareTime","func":"const fan_set_time = global.get(\"fan/set/cw\");\nconst fan_run_time = global.get(\"Fan_Run_Time_CW\");\n//var x = flow.get('Set_Time');\n//var y = flow.get('Run_Time');\nvar Fan_Set_Time_cw = Number(fan_set_time); //convert to a number\nvar Fan_Run_Time_cw = Number(fan_run_time); //convert to a number\n \n var z = Fan_Set_Time_cw*60*60;\n if(z > Fan_Run_Time_cw){\n msg.payload = \"fanopen_cw\";\n msg.topic = \"fancontrol_cw\"\n return [msg, null];\n }\n else\n {\n msg.payload = \"fanclose_cw\";\n msg.topic = \"fancontrol_cw\"\n return [null, msg];\n}\n//return msg;Set_Time","outputs":2,"noerr":0,"x":260,"y":380,"wires":[["79fcb450.d0295c","4d47e245.12526c"],["79fcb450.d0295c","ac0ec57c.a0e778"]]},{"id":"b0a6dcf5.57b7d","type":"function","z":"bdd9cacd.0c9dd8","name":"setPayload","func":"var Fan_Run_Time= {\"payload\":msg.payload};\nreturn Fan_Run_Time;","outputs":1,"noerr":0,"x":812.5000076293945,"y":373.74999809265137,"wires":[["966f9d44.ef91a"]]},{"id":"67848e64.92e2a","type":"debug","z":"bdd9cacd.0c9dd8","name":"Current Payload","active":false,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":1240,"y":380,"wires":[]},{"id":"1d9af396.53fa1c","type":"inject","z":"bdd9cacd.0c9dd8","name":"input","topic":"","payload":"1","payloadType":"num","repeat":"1","crontab":"","once":false,"onceDelay":"","x":90,"y":380,"wires":[["e6df4a18.979128"]]},{"id":"6f0b582a.bb2648","type":"debug","z":"bdd9cacd.0c9dd8","name":"Current Payload","active":false,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":320,"y":280,"wires":[]},{"id":"23d710a3.692d8","type":"debug","z":"bdd9cacd.0c9dd8","name":"Current Payload","active":false,"console":false,"complete":"payload","x":500,"y":440,"wires":[]},{"id":"b06badf9.bf1a7","type":"function","z":"bdd9cacd.0c9dd8","name":"[s] to [hh:mm:ss]","func":"// Message from preceeding node is in seconds - should be less than 24 hours (86400 seconds).\nvar time = (new Date(msg.payload * 1000)).toUTCString().match(/(\\d\\d:\\d\\d:\\d\\d)/)[0];\n// Pass on the string to the next node, what ever that may be. (groov Data Store for example).\nmsg.payload = time;\nreturn msg;","outputs":1,"noerr":0,"x":812.8571586608887,"y":320.8927869796753,"wires":[["84472a30.7375d8"]]},{"id":"84472a30.7375d8","type":"ui_text","z":"bdd9cacd.0c9dd8","group":"9bc4db16.969488","order":4,"width":0,"height":0,"name":"","label":"Running Time","format":"{{msg.payload}}","layout":"row-spread","x":1020,"y":320,"wires":[]},{"id":"966f9d44.ef91a","type":"change","z":"bdd9cacd.0c9dd8","name":"SetRun_Time_Fan_CW","rules":[{"t":"set","p":"Fan_Run_Time_CW","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1030,"y":380,"wires":[["67848e64.92e2a"]]},{"id":"ac0ec57c.a0e778","type":"change","z":"bdd9cacd.0c9dd8","name":"SetTimeFanCW","rules":[{"t":"set","p":"timer/fan/cw","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":260,"y":460,"wires":[["23d710a3.692d8"]]},{"id":"50b6eed6.5ea0f","type":"function","z":"bdd9cacd.0c9dd8","name":"","func":"const set_temp = global.get(\"active/time/reset\");\nmsg.payload =set_temp ;\nreturn msg;","outputs":1,"noerr":0,"x":980,"y":240,"wires":[["dafb387f.e20dc8"]]},{"id":"b5932092.a157c","type":"inject","z":"bdd9cacd.0c9dd8","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":840,"y":240,"wires":[["50b6eed6.5ea0f"]]},{"id":"dafb387f.e20dc8","type":"debug","z":"bdd9cacd.0c9dd8","name":"","active":false,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":1170,"y":240,"wires":[]},{"id":"4d47e245.12526c","type":"change","z":"bdd9cacd.0c9dd8","name":"SetTimeFanCW","rules":[{"t":"set","p":"timer/fan/cw","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":260,"y":320,"wires":[["6f0b582a.bb2648"]]},{"id":"418719ad.358998","type":"function","z":"bdd9cacd.0c9dd8","name":"FanTimeCW","func":"var Fan_Time_CW= {\"payload\":msg.payload.SetTime};\n\n//flow.set('order_id', O_rderID);\n//msg.topic='Set_Temp'\n\nreturn Fan_Time_CW;","outputs":1,"noerr":0,"x":270,"y":100,"wires":[["e424bdd1.e45bd","921ecc6f.e8572"]]},{"id":"e424bdd1.e45bd","type":"change","z":"bdd9cacd.0c9dd8","name":"SetTimeFanCW","rules":[{"t":"set","p":"fan/set/cw","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":500,"y":100,"wires":[[]]},{"id":"921ecc6f.e8572","type":"debug","z":"bdd9cacd.0c9dd8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":470,"y":40,"wires":[]},{"id":"48a1087d.ede4e8","type":"change","z":"bdd9cacd.0c9dd8","name":"","rules":[{"t":"change","p":"payload","pt":"msg","from":"auto","fromt":"str","to":"Auto","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"manual","fromt":"str","to":"Manual","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":680,"y":760,"wires":[[]]},{"id":"4bfe7bc.fbddd84","type":"change","z":"bdd9cacd.0c9dd8","name":"Auto/Manual var","rules":[{"t":"set","p":"AutoManual_FanCW","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":880,"y":800,"wires":[[]]},{"id":"992454f4.380578","type":"function","z":"bdd9cacd.0c9dd8","name":"turn on override","func":"const overrideAM = global.get(\"AutoManual_FanCW\") || 0;\nif(overrideAM === 0){\n msg.payload = \"manual\";\n return msg;\n} else {\n return null;\n}","outputs":1,"noerr":0,"x":640,"y":880,"wires":[["48a1087d.ede4e8","2844b61c.91a35a"]]},{"id":"b78c03.8944d4","type":"ui_dropdown","z":"bdd9cacd.0c9dd8","name":"","label":"","tooltip":"","place":"Select option","group":"9bc4db16.969488","order":1,"width":0,"height":0,"passthru":true,"options":[{"label":"MANUAL","value":"manual","type":"str"},{"label":"AUTO","value":"auto","type":"str"}],"payload":"","topic":"","x":250,"y":880,"wires":[["3d110149.c819de"]]},{"id":"3d110149.c819de","type":"switch","z":"bdd9cacd.0c9dd8","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"auto","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":410,"y":880,"wires":[["48a1087d.ede4e8","b3563d1e.2e06d","5ba0812e.40767"],["992454f4.380578"]]},{"id":"b3563d1e.2e06d","type":"change","z":"bdd9cacd.0c9dd8","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"0","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":680,"y":800,"wires":[["4bfe7bc.fbddd84"]]},{"id":"7e38d1e1.811ca","type":"inject","z":"bdd9cacd.0c9dd8","name":"","topic":"","payload":"auto","payloadType":"str","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":70,"y":880,"wires":[["b78c03.8944d4"]]},{"id":"5ba0812e.40767","type":"debug","z":"bdd9cacd.0c9dd8","name":"","active":false,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":410,"y":780,"wires":[]},{"id":"2844b61c.91a35a","type":"change","z":"bdd9cacd.0c9dd8","name":"","rules":[{"t":"change","p":"payload","pt":"msg","from":"manual","fromt":"str","to":"1","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":900,"y":880,"wires":[["4bfe7bc.fbddd84","91d94f6.ea16db"]]},{"id":"91d94f6.ea16db","type":"debug","z":"bdd9cacd.0c9dd8","name":"Output to GPIO","active":false,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":1140,"y":880,"wires":[]},{"id":"4736fecd.98621","type":"function","z":"bdd9cacd.0c9dd8","name":"","func":"const Temp_topic = msg.topic;\nconst Temp_payload = msg.payload;\nconst override = global.get(\"AutoManual_FanCW\");\n//const fanstate = global.get(\"FanState\");\nif (override !== 0) {\n if (Temp_topic === \"fancw\" && Temp_payload === \"0\") {\n msg.payload = 0;\n global.set(\"fancwState\", msg.payload);\n return msg;\n } else if(Temp_topic === \"fancw\" && Temp_payload === \"1\") {\n msg.payload = 1;\n global.set(\"fancwState\", msg.payload);\n return msg;\n } else {\n return null;\n }\n}\n\n","outputs":1,"noerr":0,"x":570,"y":1200,"wires":[["43702d97.2bc864"]]},{"id":"cf710b02.e51b68","type":"debug","z":"bdd9cacd.0c9dd8","name":"","active":false,"tosidebar":true,"console":false,"tostatus":true,"complete":"true","targetType":"full","x":430,"y":1120,"wires":[]},{"id":"43702d97.2bc864","type":"debug","z":"bdd9cacd.0c9dd8","name":"","active":false,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":690,"y":1140,"wires":[]},{"id":"ba3a1e6c.bcc3b","type":"inject","z":"bdd9cacd.0c9dd8","name":"","topic":"","payload":"1","payloadType":"str","repeat":"","crontab":"","once":true,"onceDelay":"1","x":170,"y":1200,"wires":[["c12af271.004f1","2b441702.082df8"]]},{"id":"c12af271.004f1","type":"debug","z":"bdd9cacd.0c9dd8","name":"","active":false,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":250,"y":1120,"wires":[]},{"id":"e8336526.5f3598","type":"function","z":"bdd9cacd.0c9dd8","name":"FanState","func":"//const fan_cw = global.get(\"fancwState\");\n//var fan_cwS = fan_cw.toString();\nmsg.payload =msg.payload.toString();\nreturn msg;","outputs":1,"noerr":0,"x":200,"y":1260,"wires":[["2b441702.082df8","7aa4b3dc.a6867c"]]},{"id":"43ee9ed6.aa4bc","type":"inject","z":"bdd9cacd.0c9dd8","name":"","topic":"","payload":"","payloadType":"str","repeat":"1","crontab":"","once":false,"onceDelay":0.1,"x":50,"y":1260,"wires":[[]]},{"id":"2b441702.082df8","type":"ui_switch","z":"bdd9cacd.0c9dd8","name":"","label":"FanCW","tooltip":"","group":"9bc4db16.969488","order":3,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"fancw","style":"","onvalue":"0","onvalueType":"str","onicon":"","oncolor":"","offvalue":"1","offvalueType":"str","officon":"","offcolor":"","x":380,"y":1200,"wires":[["4736fecd.98621","cf710b02.e51b68"]]},{"id":"abc83987.193fd8","type":"function","z":"bdd9cacd.0c9dd8","name":"Switching","func":"//const set_temp = global.get(\"temperature/set\");\n//const set_hum = global.get(\"humidity/set\");\n//const set_time = global.get(\"fan/set/cw\");\n//const live_temp = global.get(\"temperature/live\");\n//const live_hum = global.get(\"humidity/live\");\nconst timer_status_cw = global.get(\"timer/fan/cw\");\n//const timer_close = global.get(\"active/time/reset/close\");\n\nconst overridecw = global.get(\"AutoManual_FanCW\") || 0;\n\n//var getSetTemp = Number(set_temp);\n//var getSetHum = Number(set_hum);\n//var getLiveTemp = Number(live_temp);\n//var getLiveHum = Number(live_hum);\n\nvar on = 0;\nvar off = 1;\n\nvar fancw = 1;\n//var fa = 1;\n//var flapO = 1;\n//var falpC = 1;\n\n\nif (overridecw != 1 && timer_status_cw === \"fanopen_cw\") {\n //if(getLiveTemp < getSetTemp && getLiveHum < getSetHum){\n \n fancw = { payload:on, topic:\"fancw_on\" };\n //spray = { payload:on, topic:\"spray_on\" };\n //flapO = { payload:off, topic:\"flap_open_off\" };\n //falpC = { payload:on, topic:\"flap_close_on\" };\n \n //}\n //msg.payload = fancw;\n return fancw;\n}\nelse if (overridecw !== 1 && timer_status_cw === \"fanclose_cw\"){\n fancw = { payload:off, topic:\"fancw_on\" };\n //spray = { payload:off, topic:\"spray_off\" };\n //flapO = { payload:off, topic:\"flap_open_off\" };\n //falpC = { payload:off, topic:\"flap_close_on\" };\n //msg.payload = fancw;\n return fancw;\n }\n\n\n\n\n\n\n","outputs":1,"noerr":0,"x":280,"y":1460,"wires":[["8b892e16.7ef8c","b154ae3e.c8d58","e8336526.5f3598"]]},{"id":"8b892e16.7ef8c","type":"debug","z":"bdd9cacd.0c9dd8","name":"heater","active":false,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":490,"y":1400,"wires":[]},{"id":"25e0c20c.1daa6e","type":"inject","z":"bdd9cacd.0c9dd8","name":"","topic":"","payload":"1","payloadType":"str","repeat":"1","crontab":"","once":true,"onceDelay":"1","x":90,"y":1460,"wires":[["abc83987.193fd8"]]},{"id":"b154ae3e.c8d58","type":"change","z":"bdd9cacd.0c9dd8","name":"FanState","rules":[{"t":"set","p":"fancwState","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":480,"y":1460,"wires":[[]]},{"id":"7aa4b3dc.a6867c","type":"debug","z":"bdd9cacd.0c9dd8","name":"","active":false,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":370,"y":1260,"wires":[]},{"id":"252772d3.6881fe","type":"ui_form","z":"d20f0197.c2ede","name":"","label":"Set Time","group":"3e388c09.956444","order":2,"width":0,"height":0,"options":[{"label":"","value":"SetTime","type":"text","required":true,"rows":null}],"formValue":{"SetTime":""},"payload":"","submit":"Start","cancel":"Cancel","topic":"","x":140,"y":100,"wires":[["1830d64f.af59da","52f89bdd.df6304"]]},{"id":"1270c48b.0ab27b","type":"gate","z":"d20f0197.c2ede","name":"gate","controlTopic":"fancontrol_ccw","defaultState":"closed","openCmd":"fanopen_ccw","closeCmd":"fanclose_ccw","toggleCmd":"toggle","defaultCmd":"default","persist":false,"x":510,"y":340,"wires":[["a1b74c82.2032d"]]},{"id":"f3270d88.ee19e","type":"inject","z":"d20f0197.c2ede","name":"input","topic":"","payload":"1","payloadType":"num","repeat":"1","crontab":"","once":false,"x":610,"y":180,"wires":[["1270c48b.0ab27b"]]},{"id":"a1b74c82.2032d","type":"counter","z":"d20f0197.c2ede","name":"","init":"0","step":"1","lower":null,"upper":null,"mode":"increment","outputs":2,"x":658.499906539917,"y":339.41679668426514,"wires":[["937b0616.e07a38","8c1623c.c550be","9e886001.4da1d"],[]]},{"id":"34908ecc.cd3cb2","type":"inject","z":"d20f0197.c2ede","name":"Start","topic":"control","payload":"open","payloadType":"str","repeat":"","crontab":"","once":false,"x":611.2500057220459,"y":218.74999952316284,"wires":[["1270c48b.0ab27b"]]},{"id":"acd23e74.3e9b","type":"inject","z":"d20f0197.c2ede","name":"Stop","topic":"control","payload":"close","payloadType":"str","repeat":"","crontab":"","once":false,"x":613.000057220459,"y":261.50009870529175,"wires":[["1270c48b.0ab27b"]]},{"id":"937b0616.e07a38","type":"debug","z":"d20f0197.c2ede","name":"Current Payload","active":false,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":840,"y":400,"wires":[]},{"id":"2f1aee22.387872","type":"inject","z":"d20f0197.c2ede","name":"Reset","topic":"","payload":"0","payloadType":"str","repeat":"","crontab":"","once":false,"x":150,"y":200,"wires":[["52f89bdd.df6304"]]},{"id":"52f89bdd.df6304","type":"function","z":"d20f0197.c2ede","name":"Reset Counter","func":"msg.reset=msg.payload\nreturn msg;","outputs":1,"noerr":0,"x":340,"y":200,"wires":[["a1b74c82.2032d"]]},{"id":"47defa75.3183d4","type":"function","z":"d20f0197.c2ede","name":"compareTime","func":"const fan_set_time = global.get(\"fan/set/ccw\");\nconst fan_run_time = global.get(\"Fan_Run_Time_CCW\");\n//var x = flow.get('Set_Time');\n//var y = flow.get('Run_Time');\nvar Fan_Set_Time_ccw = Number(fan_set_time); //convert to a number\nvar Fan_Run_Time_ccw = Number(fan_run_time); //convert to a number\n \n var z = Fan_Set_Time_ccw*60*60;\n if(z > Fan_Run_Time_ccw){\n msg.payload = \"fanopen_ccw\";\n msg.topic = \"fancontrol_ccw\"\n return [msg, null];\n }\n else\n {\n msg.payload = \"fanclose_ccw\";\n msg.topic = \"fancontrol_ccw\"\n return [null, msg];\n}\n//return msg;Set_Time","outputs":2,"noerr":0,"x":280,"y":340,"wires":[["1270c48b.0ab27b","ec0831a.2be70d"],["1270c48b.0ab27b","cbd8242f.9bf738"]]},{"id":"8c1623c.c550be","type":"function","z":"d20f0197.c2ede","name":"setPayload","func":"var Fan_Run_Time= {\"payload\":msg.payload};\nreturn Fan_Run_Time;","outputs":1,"noerr":0,"x":832.5000076293945,"y":333.74999809265137,"wires":[["9d48a86.bdfb758"]]},{"id":"f74f6c08.173b1","type":"debug","z":"d20f0197.c2ede","name":"Current Payload","active":false,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":1260,"y":340,"wires":[]},{"id":"4fb30591.c1de8c","type":"inject","z":"d20f0197.c2ede","name":"input","topic":"","payload":"1","payloadType":"num","repeat":"1","crontab":"","once":false,"onceDelay":"","x":110,"y":340,"wires":[["47defa75.3183d4"]]},{"id":"41b1e5f3.59ee1c","type":"debug","z":"d20f0197.c2ede","name":"Current Payload","active":false,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":340,"y":240,"wires":[]},{"id":"df4fdfa2.bb21c","type":"debug","z":"d20f0197.c2ede","name":"Current Payload","active":false,"console":false,"complete":"payload","x":520,"y":400,"wires":[]},{"id":"9e886001.4da1d","type":"function","z":"d20f0197.c2ede","name":"[s] to [hh:mm:ss]","func":"// Message from preceeding node is in seconds - should be less than 24 hours (86400 seconds).\nvar time = (new Date(msg.payload * 1000)).toUTCString().match(/(\\d\\d:\\d\\d:\\d\\d)/)[0];\n// Pass on the string to the next node, what ever that may be. (groov Data Store for example).\nmsg.payload = time;\nreturn msg;","outputs":1,"noerr":0,"x":832.8571586608887,"y":280.8927869796753,"wires":[["d5bf2729.1bb168"]]},{"id":"d5bf2729.1bb168","type":"ui_text","z":"d20f0197.c2ede","group":"3e388c09.956444","order":4,"width":0,"height":0,"name":"","label":"Running Time","format":"{{msg.payload}}","layout":"row-spread","x":1046.7144203186035,"y":280.2579388618469,"wires":[]},{"id":"9d48a86.bdfb758","type":"change","z":"d20f0197.c2ede","name":"SetRun_Time_Fan_CCW","rules":[{"t":"set","p":"Fan_Run_Time_CCW","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1050,"y":340,"wires":[["f74f6c08.173b1"]]},{"id":"cbd8242f.9bf738","type":"change","z":"d20f0197.c2ede","name":"SetTimeFanCCW","rules":[{"t":"set","p":"timer/fan/ccw","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":290,"y":420,"wires":[["df4fdfa2.bb21c"]]},{"id":"52b9a322.181fcc","type":"function","z":"d20f0197.c2ede","name":"","func":"const set_temp = global.get(\"active/time/reset\");\nmsg.payload =set_temp ;\nreturn msg;","outputs":1,"noerr":0,"x":1000,"y":200,"wires":[["31938fa2.96f0f"]]},{"id":"b3ce1e55.abddd","type":"inject","z":"d20f0197.c2ede","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":860,"y":200,"wires":[["52b9a322.181fcc"]]},{"id":"31938fa2.96f0f","type":"debug","z":"d20f0197.c2ede","name":"","active":false,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":1190,"y":200,"wires":[]},{"id":"ec0831a.2be70d","type":"change","z":"d20f0197.c2ede","name":"SetTimeFanCCW","rules":[{"t":"set","p":"timer/fan/ccw","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":290,"y":280,"wires":[["41b1e5f3.59ee1c"]]},{"id":"1830d64f.af59da","type":"function","z":"d20f0197.c2ede","name":"FanTimeCCW","func":"var Fan_Time_CCW= {\"payload\":msg.payload.SetTime};\n\n//flow.set('order_id', O_rderID);\n//msg.topic='Set_Temp'\n\nreturn Fan_Time_CCW;","outputs":1,"noerr":0,"x":340,"y":100,"wires":[["14a41805.93e838","92b2493c.ba5028"]]},{"id":"14a41805.93e838","type":"change","z":"d20f0197.c2ede","name":"SetTimeFanCCW","rules":[{"t":"set","p":"fan/set/ccw","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":570,"y":100,"wires":[[]]},{"id":"92b2493c.ba5028","type":"debug","z":"d20f0197.c2ede","name":"","active":false,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":490,"y":40,"wires":[]},{"id":"7c7cd9f5.591ae8","type":"change","z":"d20f0197.c2ede","name":"","rules":[{"t":"change","p":"payload","pt":"msg","from":"auto","fromt":"str","to":"Auto","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"manual","fromt":"str","to":"Manual","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":740,"y":540,"wires":[[]]},{"id":"da0b9a69.b0f018","type":"change","z":"d20f0197.c2ede","name":"Auto/Manual var","rules":[{"t":"set","p":"AutoManual_FanCCW","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":940,"y":580,"wires":[[]]},{"id":"5f08b1f3.a03a1","type":"function","z":"d20f0197.c2ede","name":"turn on override","func":"const overrideAM = global.get(\"AutoManual_FanCCW\") || 0;\nif(overrideAM === 0){\n msg.payload = \"manual\";\n return msg;\n} else {\n return null;\n}","outputs":1,"noerr":0,"x":700,"y":660,"wires":[["7c7cd9f5.591ae8","daa3904e.299f6"]]},{"id":"e12560c8.6aee2","type":"ui_dropdown","z":"d20f0197.c2ede","name":"","label":"","tooltip":"","place":"Select option","group":"3e388c09.956444","order":1,"width":0,"height":0,"passthru":true,"options":[{"label":"MANUAL","value":"manual","type":"str"},{"label":"AUTO","value":"auto","type":"str"}],"payload":"","topic":"","x":310,"y":660,"wires":[["6ce54fa6.249e1"]]},{"id":"6ce54fa6.249e1","type":"switch","z":"d20f0197.c2ede","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"auto","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":470,"y":660,"wires":[["7c7cd9f5.591ae8","5c81ada3.2706b4","8ddb0d42.b30cf"],["5f08b1f3.a03a1"]]},{"id":"5c81ada3.2706b4","type":"change","z":"d20f0197.c2ede","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"0","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":740,"y":580,"wires":[["da0b9a69.b0f018"]]},{"id":"707ac280.cbf67c","type":"inject","z":"d20f0197.c2ede","name":"","topic":"","payload":"auto","payloadType":"str","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":130,"y":660,"wires":[["e12560c8.6aee2"]]},{"id":"8ddb0d42.b30cf","type":"debug","z":"d20f0197.c2ede","name":"","active":false,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":470,"y":560,"wires":[]},{"id":"daa3904e.299f6","type":"change","z":"d20f0197.c2ede","name":"","rules":[{"t":"change","p":"payload","pt":"msg","from":"manual","fromt":"str","to":"1","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":960,"y":660,"wires":[["da0b9a69.b0f018","7967305c.c5a68"]]},{"id":"7967305c.c5a68","type":"debug","z":"d20f0197.c2ede","name":"Output to GPIO","active":false,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":1200,"y":660,"wires":[]},{"id":"40ebcbc7.1d8884","type":"function","z":"d20f0197.c2ede","name":"","func":"const Temp_topic = msg.topic;\nconst Temp_payload = msg.payload;\nconst override = global.get(\"AutoManual_FanCCW\");\n//const fanstate = global.get(\"FanState\");\nif (override !== 0) {\n if (Temp_topic === \"fanccw\" && Temp_payload === \"0\") {\n msg.payload = 0;\n global.set(\"fanccwState\", msg.payload);\n return msg;\n } else if(Temp_topic === \"fanccw\" && Temp_payload === \"1\") {\n msg.payload = 1;\n global.set(\"fanccwState\", msg.payload);\n return msg;\n } else {\n return null;\n }\n}\n\n","outputs":1,"noerr":0,"x":640,"y":900,"wires":[["f4e62ed7.31507"]]},{"id":"df9eb1cc.450e5","type":"debug","z":"d20f0197.c2ede","name":"","active":false,"tosidebar":true,"console":false,"tostatus":true,"complete":"true","targetType":"full","x":500,"y":820,"wires":[]},{"id":"f4e62ed7.31507","type":"debug","z":"d20f0197.c2ede","name":"","active":false,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":760,"y":840,"wires":[]},{"id":"2ce8e40f.f3f43c","type":"inject","z":"d20f0197.c2ede","name":"","topic":"","payload":"1","payloadType":"str","repeat":"","crontab":"","once":true,"onceDelay":"1","x":240,"y":900,"wires":[["9d83fa8b.7d34b8","e19bfda9.fdc0a"]]},{"id":"9d83fa8b.7d34b8","type":"debug","z":"d20f0197.c2ede","name":"","active":false,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":320,"y":820,"wires":[]},{"id":"a881ce34.2c8e7","type":"function","z":"d20f0197.c2ede","name":"FanState","func":"//const fan_ccw = global.get(\"fanccwState\");\n//var fan_ccwS = fan_ccw.toString();\nmsg.payload =msg.payload.toString();\nreturn msg;","outputs":1,"noerr":0,"x":250,"y":960,"wires":[["e19bfda9.fdc0a","b98b818c.11ff7"]]},{"id":"9df58752.515cf8","type":"inject","z":"d20f0197.c2ede","name":"","topic":"","payload":"","payloadType":"str","repeat":"1","crontab":"","once":false,"onceDelay":0.1,"x":120,"y":960,"wires":[[]]},{"id":"e19bfda9.fdc0a","type":"ui_switch","z":"d20f0197.c2ede","name":"","label":"FanCCW","tooltip":"","group":"3e388c09.956444","order":3,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"fanccw","style":"","onvalue":"0","onvalueType":"str","onicon":"","oncolor":"","offvalue":"1","offvalueType":"str","officon":"","offcolor":"","x":450,"y":900,"wires":[["40ebcbc7.1d8884","df9eb1cc.450e5"]]},{"id":"b98b818c.11ff7","type":"debug","z":"d20f0197.c2ede","name":"","active":false,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":440,"y":960,"wires":[]},{"id":"5c420a09.487204","type":"function","z":"d20f0197.c2ede","name":"Switching","func":"//const set_temp = global.get(\"temperature/set\");\n//const set_hum = global.get(\"humidity/set\");\n//const set_time = global.get(\"fan/set/ccw\");\n//const live_temp = global.get(\"temperature/live\");\n//const live_hum = global.get(\"humidity/live\");\nconst timer_status_ccw = global.get(\"timer/fan/ccw\");\n//const timer_close = global.get(\"active/time/reset/close\");\n\nconst overrideccw = global.get(\"AutoManual_FanCCW\") || 0;\n\n//var getSetTemp = Number(set_temp);\n//var getSetHum = Number(set_hum);\n//var getLiveTemp = Number(live_temp);\n//var getLiveHum = Number(live_hum);\n\nvar on = 0;\nvar off = 1;\n\nvar fanccw = 1;\n//var fa = 1;\n//var flapO = 1;\n//var falpC = 1;\n\n\nif (overrideccw != 1 && timer_status_ccw === \"fanopen_ccw\") {\n //if(getLiveTemp < getSetTemp && getLiveHum < getSetHum){\n \n fanccw = { payload:on, topic:\"fanccw_on\" };\n //spray = { payload:on, topic:\"spray_on\" };\n //flapO = { payload:off, topic:\"flap_open_off\" };\n //falpC = { payload:on, topic:\"flap_close_on\" };\n \n //}\n //msg.payload = fancw;\n return fanccw;\n}\nelse if (overrideccw !== 1 && timer_status_ccw === \"fanclose_ccw\"){\n fanccw = { payload:off, topic:\"fanccw_on\" };\n //spray = { payload:off, topic:\"spray_off\" };\n //flapO = { payload:off, topic:\"flap_open_off\" };\n //falpC = { payload:off, topic:\"flap_close_on\" };\n //msg.payload = fancw;\n return fanccw;\n }\n\n\n\n\n\n\n","outputs":1,"noerr":0,"x":340,"y":1140,"wires":[["55407b61.bdc3a4","98a95272.7f1eb","a881ce34.2c8e7"]]},{"id":"55407b61.bdc3a4","type":"debug","z":"d20f0197.c2ede","name":"heater","active":false,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":550,"y":1080,"wires":[]},{"id":"f4e29dfb.cced6","type":"inject","z":"d20f0197.c2ede","name":"","topic":"","payload":"1","payloadType":"str","repeat":"1","crontab":"","once":true,"onceDelay":"1","x":150,"y":1140,"wires":[["5c420a09.487204"]]},{"id":"98a95272.7f1eb","type":"change","z":"d20f0197.c2ede","name":"HeaterState","rules":[{"t":"set","p":"fanccwState","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":550,"y":1140,"wires":[[]]},{"id":"b3b8d1e2.dfa8e","type":"rpi-gpio out","z":"fc826377.b12ce","name":"","pin":"40","set":true,"level":"1","freq":"","out":"out","x":1540,"y":160,"wires":[]},{"id":"e1b7b032.8052b","type":"rpi-gpio out","z":"fc826377.b12ce","name":"","pin":"38","set":true,"level":"1","freq":"","out":"out","x":460,"y":1320,"wires":[]},{"id":"341cf0cc.f3535","type":"rpi-gpio out","z":"fc826377.b12ce","name":"","pin":"37","set":true,"level":"1","freq":"","out":"out","x":580,"y":540,"wires":[]},{"id":"9833c09b.99a1b","type":"rpi-gpio out","z":"fc826377.b12ce","name":"","pin":"36","set":true,"level":"1","freq":"","out":"out","x":460,"y":1120,"wires":[]},{"id":"c989542.634daa8","type":"rpi-gpio out","z":"fc826377.b12ce","name":"","pin":"35","set":true,"level":"1","freq":"","out":"out","x":1500,"y":520,"wires":[]},{"id":"552c3783.b923d8","type":"comment","z":"fc826377.b12ce","name":"Fl-open","info":"","x":830,"y":140,"wires":[]},{"id":"1e9a908f.3da26f","type":"comment","z":"fc826377.b12ce","name":"Fan_CW","info":"","x":80,"y":1200,"wires":[]},{"id":"5b599222.82c84c","type":"comment","z":"fc826377.b12ce","name":"Spray","info":"","x":70,"y":440,"wires":[]},{"id":"6a9b4a5f.4638b4","type":"comment","z":"fc826377.b12ce","name":"Fan-CCW","info":"","x":80,"y":1000,"wires":[]},{"id":"387ef214.3fe62e","type":"comment","z":"fc826377.b12ce","name":"Fl-close","info":"","x":830,"y":480,"wires":[]},{"id":"807d1ba5.b09808","type":"inject","z":"fc826377.b12ce","name":"","topic":"","payload":"0","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":210,"y":1240,"wires":[["e1b7b032.8052b"]]},{"id":"39f60b04.b18714","type":"inject","z":"fc826377.b12ce","name":"","topic":"","payload":"1","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":210,"y":1280,"wires":[["e1b7b032.8052b"]]},{"id":"9f2a224d.a3b22","type":"inject","z":"fc826377.b12ce","name":"","topic":"","payload":"0","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":210,"y":1040,"wires":[["9833c09b.99a1b"]]},{"id":"30706f2e.27b9e","type":"inject","z":"fc826377.b12ce","name":"","topic":"","payload":"1","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":210,"y":1080,"wires":[["9833c09b.99a1b"]]},{"id":"af6b6504.ab4848","type":"rpi-gpio out","z":"fc826377.b12ce","name":"","pin":"33","set":true,"level":"1","freq":"","out":"out","x":640,"y":160,"wires":[]},{"id":"ca6decd5.5733e","type":"comment","z":"fc826377.b12ce","name":"Heater","info":"","x":50,"y":100,"wires":[]},{"id":"940757e2.6fd1a8","type":"function","z":"fc826377.b12ce","name":"Heater","func":"const heater = global.get(\"heaterState\");\nmsg.payload = heater ;\nreturn msg;","outputs":1,"noerr":0,"x":210,"y":180,"wires":[["f027871b.7d2338","51ebc53e.a3258c"]]},{"id":"e9964b70.102848","type":"inject","z":"fc826377.b12ce","name":"","topic":"","payload":"","payloadType":"str","repeat":"2","crontab":"","once":false,"onceDelay":0.1,"x":70,"y":180,"wires":[["940757e2.6fd1a8"]]},{"id":"f027871b.7d2338","type":"debug","z":"fc826377.b12ce","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":170,"y":240,"wires":[]},{"id":"39ebee41.7a71b2","type":"function","z":"fc826377.b12ce","name":"Spray","func":"const spray = global.get(\"sprayState\");\nmsg.payload = spray ;\nreturn msg;","outputs":1,"noerr":0,"x":190,"y":520,"wires":[["9f1883f8.8b7d9","a58be043.4b2b9","f68efe3c.fde128"]]},{"id":"5ae61726.f94f08","type":"inject","z":"fc826377.b12ce","name":"","topic":"","payload":"","payloadType":"str","repeat":"2","crontab":"","once":false,"onceDelay":0.1,"x":50,"y":520,"wires":[["39ebee41.7a71b2"]]},{"id":"9f1883f8.8b7d9","type":"debug","z":"fc826377.b12ce","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":190,"y":580,"wires":[]},{"id":"ecdeb652.53a1e8","type":"function","z":"fc826377.b12ce","name":"FanCCW","func":"const fanccw = global.get(\"fanccwState\");\nmsg.payload = fanccw ;\nreturn msg;","outputs":1,"noerr":0,"x":280,"y":1120,"wires":[["a053b10a.d0dda","9833c09b.99a1b","960a1ca8.1c271"]]},{"id":"c9b58d75.1d4c7","type":"inject","z":"fc826377.b12ce","name":"","topic":"","payload":"","payloadType":"str","repeat":"1","crontab":"","once":false,"onceDelay":0.1,"x":90,"y":1120,"wires":[["ecdeb652.53a1e8"]]},{"id":"a053b10a.d0dda","type":"debug","z":"fc826377.b12ce","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":290,"y":1180,"wires":[]},{"id":"4d9a0e49.aa73c","type":"function","z":"fc826377.b12ce","name":"FanCW","func":"const fancw = global.get(\"fancwState\");\nmsg.payload = fancw ;\nreturn msg;","outputs":1,"noerr":0,"x":260,"y":1320,"wires":[["759ef2d3.90f4fc","e1b7b032.8052b","18997d26.d5fd43"]]},{"id":"5187bb79.4b5dd4","type":"inject","z":"fc826377.b12ce","name":"","topic":"","payload":"","payloadType":"str","repeat":"1","crontab":"","once":false,"onceDelay":0.1,"x":70,"y":1320,"wires":[["4d9a0e49.aa73c"]]},{"id":"759ef2d3.90f4fc","type":"debug","z":"fc826377.b12ce","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":270,"y":1380,"wires":[]},{"id":"4271041.7870dfc","type":"change","z":"fc826377.b12ce","name":"","rules":[{"t":"change","p":"payload","pt":"msg","from":"0","fromt":"num","to":"ON","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"1","fromt":"num","to":"OFF","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":400,"y":220,"wires":[["80d4e9e3.599268"]]},{"id":"80d4e9e3.599268","type":"ui_text","z":"fc826377.b12ce","group":"","order":1,"width":0,"height":0,"name":"","label":"Heater Status","format":"{{msg.payload}}","layout":"row-spread","x":600,"y":220,"wires":[]},{"id":"a58be043.4b2b9","type":"change","z":"fc826377.b12ce","name":"","rules":[{"t":"change","p":"payload","pt":"msg","from":"0","fromt":"num","to":"ON","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"1","fromt":"num","to":"OFF","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":400,"y":600,"wires":[["6058868a.aee2c8"]]},{"id":"6058868a.aee2c8","type":"ui_text","z":"fc826377.b12ce","group":"","order":2,"width":0,"height":0,"name":"","label":"Spray Status","format":"{{msg.payload}}","layout":"row-spread","x":570,"y":600,"wires":[]},{"id":"960a1ca8.1c271","type":"change","z":"fc826377.b12ce","name":"","rules":[{"t":"change","p":"payload","pt":"msg","from":"0","fromt":"num","to":"ON","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"1","fromt":"num","to":"OFF","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":520,"y":1180,"wires":[["1c646fd5.50b97"]]},{"id":"1c646fd5.50b97","type":"ui_text","z":"fc826377.b12ce","group":"","order":6,"width":0,"height":0,"name":"","label":"Fan CCW Status","format":"{{msg.payload}}","layout":"row-spread","x":730,"y":1180,"wires":[]},{"id":"18997d26.d5fd43","type":"change","z":"fc826377.b12ce","name":"","rules":[{"t":"change","p":"payload","pt":"msg","from":"0","fromt":"num","to":"ON","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"1","fromt":"num","to":"OFF","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":480,"y":1380,"wires":[["7e0fd8f6.678118"]]},{"id":"7e0fd8f6.678118","type":"ui_text","z":"fc826377.b12ce","group":"","order":5,"width":0,"height":0,"name":"","label":"Fan CW Status","format":"{{msg.payload}}","layout":"row-spread","x":680,"y":1380,"wires":[]},{"id":"bea28fb0.a98fd","type":"function","z":"fc826377.b12ce","name":"Flap Open","func":"const flapOpen = global.get(\"flap_openState\");\nmsg.payload = flapOpen ;\nreturn msg;","outputs":1,"noerr":0,"x":990,"y":200,"wires":[["14f3f279.7a2e3e","d0f1715e.5bf96"]]},{"id":"9616f8ad.e18828","type":"inject","z":"fc826377.b12ce","name":"","topic":"","payload":"","payloadType":"str","repeat":"2","crontab":"","once":false,"onceDelay":0.1,"x":830,"y":200,"wires":[["bea28fb0.a98fd"]]},{"id":"14f3f279.7a2e3e","type":"debug","z":"fc826377.b12ce","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":990,"y":280,"wires":[]},{"id":"7d9983ff.7bf72c","type":"change","z":"fc826377.b12ce","name":"","rules":[{"t":"change","p":"payload","pt":"msg","from":"0","fromt":"num","to":"ON","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"1","fromt":"num","to":"OFF","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1200,"y":240,"wires":[["e58a2719.db3a38"]]},{"id":"e58a2719.db3a38","type":"ui_text","z":"fc826377.b12ce","group":"","order":4,"width":0,"height":0,"name":"","label":"Flap Open","format":"{{msg.payload}}","layout":"row-spread","x":1410,"y":240,"wires":[]},{"id":"431bb3b6.cd9b0c","type":"function","z":"fc826377.b12ce","name":"Flap Close","func":"const flapClose = global.get(\"flap_closeState\");\nmsg.payload = flapClose ;\nreturn msg;","outputs":1,"noerr":0,"x":990,"y":540,"wires":[["3a054698.03ec4a","64549bd3.3623e4"]]},{"id":"32803528.f1657a","type":"inject","z":"fc826377.b12ce","name":"","topic":"","payload":"","payloadType":"str","repeat":"2","crontab":"","once":false,"onceDelay":0.1,"x":830,"y":540,"wires":[["431bb3b6.cd9b0c"]]},{"id":"3a054698.03ec4a","type":"debug","z":"fc826377.b12ce","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":990,"y":620,"wires":[]},{"id":"f720e9ff.541b28","type":"change","z":"fc826377.b12ce","name":"","rules":[{"t":"change","p":"payload","pt":"msg","from":"0","fromt":"num","to":"ON","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"1","fromt":"num","to":"OFF","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1220,"y":580,"wires":[["3831c3ea.efe28c"]]},{"id":"3831c3ea.efe28c","type":"ui_text","z":"fc826377.b12ce","group":"","order":3,"width":0,"height":0,"name":"","label":"Flap Close","format":"{{msg.payload}}","layout":"row-spread","x":1430,"y":580,"wires":[]},{"id":"51ebc53e.a3258c","type":"rbe","z":"fc826377.b12ce","name":"","func":"rbei","gap":"","start":"","inout":"out","property":"payload","x":270,"y":120,"wires":[["517a32e1.b6f39c","4271041.7870dfc","9e3f23a.d74b7e"]]},{"id":"bb2103a6.3b421","type":"delay","z":"fc826377.b12ce","name":"","pauseType":"delay","timeout":"20","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":540,"y":60,"wires":[["585066e2.6408b"]]},{"id":"a65ae589.e5b778","type":"delay","z":"fc826377.b12ce","name":"","pauseType":"delay","timeout":"20","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":500,"y":400,"wires":[["95edcd7f.efe6c8"]]},{"id":"d0f1715e.5bf96","type":"rbe","z":"fc826377.b12ce","name":"","func":"rbei","gap":"","start":"","inout":"out","property":"payload","x":1110,"y":160,"wires":[["65841411.464f4c","7d9983ff.7bf72c","5715289c.cbf4e8"]]},{"id":"5de89057.28973","type":"delay","z":"fc826377.b12ce","name":"","pauseType":"delay","timeout":"10","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1400,"y":100,"wires":[["b3b8d1e2.dfa8e"]]},{"id":"64549bd3.3623e4","type":"rbe","z":"fc826377.b12ce","name":"","func":"rbei","gap":"","start":"","inout":"out","property":"payload","x":1030,"y":480,"wires":[["8a240484.9785b8","f720e9ff.541b28"]]},{"id":"95eed759.0f9158","type":"delay","z":"fc826377.b12ce","name":"","pauseType":"delay","timeout":"10","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1360,"y":460,"wires":[["c989542.634daa8"]]},{"id":"1b99d1e5.4d095e","type":"rbe","z":"e661d7b9.d19188","name":"","func":"rbei","gap":"30%","start":"","inout":"out","property":"payload","x":230,"y":100,"wires":[["cd20e435.2545b8","31bdfc21.b40a04","1c9c9098.808e2f","3316b8c.d14e148","4b39a832.3c0bc","46b6d760.dd0f18"]]},{"id":"517a32e1.b6f39c","type":"switch","z":"fc826377.b12ce","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"str"},{"t":"eq","v":"1","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":410,"y":120,"wires":[["bb2103a6.3b421"],["af6b6504.ab4848"]]},{"id":"52a7c145.0237d","type":"switch","z":"fc826377.b12ce","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"str"},{"t":"eq","v":"1","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":390,"y":460,"wires":[["a65ae589.e5b778"],["341cf0cc.f3535"]]},{"id":"8a240484.9785b8","type":"switch","z":"fc826377.b12ce","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"str"},{"t":"eq","v":"1","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":1190,"y":480,"wires":[["95eed759.0f9158"],["c989542.634daa8"]]},{"id":"65841411.464f4c","type":"switch","z":"fc826377.b12ce","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"str"},{"t":"eq","v":"1","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":1230,"y":120,"wires":[["5de89057.28973"],["b3b8d1e2.dfa8e"]]},{"id":"ae8eeca2.e53ca","type":"inject","z":"e661d7b9.d19188","name":"","topic":"","payload":"51","payloadType":"num","repeat":"1","crontab":"","once":true,"onceDelay":0.1,"x":1110,"y":340,"wires":[[]]},{"id":"671ddf93.765b6","type":"inject","z":"e661d7b9.d19188","name":"","topic":"","payload":"60","payloadType":"num","repeat":"1","crontab":"","once":true,"onceDelay":0.1,"x":1110,"y":400,"wires":[[]]},{"id":"b85d0a87.d8098","type":"debug","z":"e661d7b9.d19188","name":"","active":false,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":1250,"y":440,"wires":[]},{"id":"7c14ff8e.85f21","type":"debug","z":"e661d7b9.d19188","name":"","active":false,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":1250,"y":480,"wires":[]},{"id":"1e4515e6.16c862","type":"debug","z":"e661d7b9.d19188","name":"","active":false,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":1290,"y":780,"wires":[]},{"id":"132b6e52.77128a","type":"debug","z":"e661d7b9.d19188","name":"","active":false,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":1290,"y":820,"wires":[]},{"id":"4945371b.f5af3","type":"inject","z":"fc826377.b12ce","name":"","topic":"","payload":"1","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":1290,"y":160,"wires":[["b3b8d1e2.dfa8e"]]},{"id":"2b76a439.ecd654","type":"inject","z":"fc826377.b12ce","name":"","topic":"","payload":"1","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":430,"y":160,"wires":[["af6b6504.ab4848"]]},{"id":"2bc13daa.a4ce8a","type":"function","z":"e661d7b9.d19188","name":"","func":"var tempV = msg.payload;\nvar getLiveTemp = Number(tempV);\nconst set_tempT = global.get(\"temperature/set\");\nvar getSetTempT = Number(set_tempT);\nvar maxTemp = getSetTempT + 4;\nif (getLiveTemp > maxTemp){\n msg.payload = \"1\";\n return msg;\n}\n","outputs":1,"noerr":0,"x":190,"y":440,"wires":[["1bfe0df3.0cfa2a","57020049.78341","f11a5a85.6049f8"]]},{"id":"1bfe0df3.0cfa2a","type":"debug","z":"e661d7b9.d19188","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":380,"y":440,"wires":[]},{"id":"57020049.78341","type":"change","z":"e661d7b9.d19188","name":"HeaterState","rules":[{"t":"set","p":"heaterState","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":360,"y":500,"wires":[[]]},{"id":"f11a5a85.6049f8","type":"ui_toast","z":"e661d7b9.d19188","position":"top right","displayTime":"3","highlight":"","sendall":true,"outputs":0,"ok":"OK","cancel":"","raw":false,"topic":"","name":"","x":150,"y":540,"wires":[]},{"id":"1d87e228.e28ee6","type":"inject","z":"fc826377.b12ce","name":"","topic":"","payload":"1","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":410,"y":540,"wires":[["341cf0cc.f3535"]]},{"id":"30a17aa1.7eb306","type":"ui_text","z":"e661d7b9.d19188","group":"cb463a47.03cb98","order":2,"width":0,"height":0,"name":"","label":"Humidity","format":"{{msg.payload}}","layout":"row-spread","x":400,"y":1140,"wires":[]},{"id":"342f71b3.00f6e6","type":"ui_chart","z":"e661d7b9.d19188","name":"","group":"cb463a47.03cb98","order":3,"width":0,"height":0,"label":"Humidity","chartType":"line","legend":"false","xformat":"dd HH:mm","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":"24","removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"outputs":1,"x":400,"y":1180,"wires":[[]]},{"id":"4b39a832.3c0bc","type":"ui_text","z":"e661d7b9.d19188","group":"66f5af7f.b94058","order":2,"width":0,"height":0,"name":"","label":"Temperature","format":"{{msg.payload}}","layout":"row-spread","x":670,"y":40,"wires":[]},{"id":"46b6d760.dd0f18","type":"ui_chart","z":"e661d7b9.d19188","name":"","group":"66f5af7f.b94058","order":3,"width":0,"height":0,"label":"Temperature","chartType":"line","legend":"false","xformat":"dd HH:mm","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":"24","removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"outputs":1,"x":670,"y":80,"wires":[[]]},{"id":"dce2a0e7.3a0378","type":"ui_text","z":"34243684.8b511a","group":"66f5af7f.b94058","order":1,"width":0,"height":0,"name":"","label":"Set Temperature","format":"{{msg.payload}}","layout":"row-spread","x":550,"y":260,"wires":[]},{"id":"a6ddaf59.3e1a5","type":"ui_text","z":"34243684.8b511a","group":"cb463a47.03cb98","order":1,"width":0,"height":0,"name":"","label":"Set Humidity","format":"{{msg.payload}}","layout":"row-spread","x":530,"y":300,"wires":[]},{"id":"519fdde8.d80804","type":"ui_text","z":"34243684.8b511a","group":"6c2b803e.b7681","order":2,"width":0,"height":0,"name":"","label":"Set Time","format":"{{msg.payload}}","layout":"row-spread","x":520,"y":340,"wires":[]},{"id":"35702cde.e4e11c","type":"ui_text","z":"34243684.8b511a","group":"6c2b803e.b7681","order":1,"width":0,"height":0,"name":"","label":"Running Time","format":"{{msg.payload}}","layout":"row-spread","x":1020,"y":440,"wires":[]},{"id":"38d1c497.44f6b4","type":"function","z":"e661d7b9.d19188","name":"","func":"var humV = msg.payload;\nvar getLiveHum = Number(humV);\nconst set_humT = global.get(\"humidity/set\");\nvar getSetHumH = Number(set_humT);\nvar maxHum = getSetHumH + 15;\nif (getLiveHum > maxHum){\n msg.payload = \"1\";\n return msg;\n}\n","outputs":1,"noerr":0,"x":310,"y":1240,"wires":[["b72df17c.44a1e","57892032.822d38","1ff1f041.08f9d8"]]},{"id":"b72df17c.44a1e","type":"debug","z":"e661d7b9.d19188","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":500,"y":1260,"wires":[]},{"id":"57892032.822d38","type":"ui_toast","z":"e661d7b9.d19188","position":"top right","displayTime":"3","highlight":"","sendall":true,"outputs":0,"ok":"OK","cancel":"","raw":false,"topic":"","name":"","x":270,"y":1360,"wires":[]},{"id":"1ff1f041.08f9d8","type":"change","z":"e661d7b9.d19188","name":"SprayState","rules":[{"t":"set","p":"sprayState","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":510,"y":1320,"wires":[[]]},{"id":"f68efe3c.fde128","type":"rbe","z":"fc826377.b12ce","name":"","func":"rbei","gap":"","start":"","inout":"out","property":"payload","x":230,"y":460,"wires":[["52a7c145.0237d","2dcac39f.a5cad4"]]},{"id":"2dcac39f.a5cad4","type":"trigger","z":"fc826377.b12ce","op1":"connected","op2":"no command","op1type":"str","op2type":"str","duration":"120","extend":true,"units":"s","reset":"","bytopic":"all","name":"","x":270,"y":660,"wires":[["43334ffb.871448"]]},{"id":"43334ffb.871448","type":"function","z":"fc826377.b12ce","name":"","func":"var flag = msg.payload;\nif (flag === \"no command\"){\n msg.payload = \"1\";\n return msg;\n}\n","outputs":1,"noerr":0,"x":410,"y":660,"wires":[["c7fe8575.1bed9"]]},{"id":"c7fe8575.1bed9","type":"change","z":"fc826377.b12ce","name":"SprayState","rules":[{"t":"set","p":"sprayState","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":570,"y":660,"wires":[[]]},{"id":"5715289c.cbf4e8","type":"trigger","z":"fc826377.b12ce","op1":"connected","op2":"no command","op1type":"str","op2type":"str","duration":"3","extend":true,"units":"min","reset":"","bytopic":"all","name":"","x":1150,"y":320,"wires":[["f90afec7.b1e02"]]},{"id":"f90afec7.b1e02","type":"function","z":"fc826377.b12ce","name":"","func":"var flag = msg.payload;\nif (flag === \"no command\"){\n msg.payload = \"1\";\n return msg;\n}\n","outputs":1,"noerr":0,"x":1310,"y":320,"wires":[["bb6c5c16.11404"]]},{"id":"bb6c5c16.11404","type":"change","z":"fc826377.b12ce","name":"FlapOpenState","rules":[{"t":"set","p":"flap_openState","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1480,"y":320,"wires":[[]]},{"id":"9e3f23a.d74b7e","type":"trigger","z":"fc826377.b12ce","op1":"connected","op2":"no command","op1type":"str","op2type":"str","duration":"40","extend":true,"units":"s","reset":"","bytopic":"all","name":"","x":350,"y":280,"wires":[["ab850923.6159d8"]]},{"id":"ab850923.6159d8","type":"function","z":"fc826377.b12ce","name":"","func":"var flag = msg.payload;\nif (flag === \"no command\"){\n msg.payload = \"1\";\n return msg;\n}\n","outputs":1,"noerr":0,"x":490,"y":280,"wires":[["cbd84ea1.63cf5"]]},{"id":"cbd84ea1.63cf5","type":"change","z":"fc826377.b12ce","name":"HeaterState","rules":[{"t":"set","p":"heaterState","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":630,"y":280,"wires":[[]]},{"id":"1aabaee5.88c899","type":"delay","z":"e661d7b9.d19188","name":"","pauseType":"delay","timeout":"4","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1480,"y":400,"wires":[["7caa534b.3c131c"]]},{"id":"174bae22.98755a","type":"delay","z":"e661d7b9.d19188","name":"","pauseType":"delay","timeout":"4","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1480,"y":800,"wires":[["4089697e.6beba8"]]},{"id":"585066e2.6408b","type":"function","z":"fc826377.b12ce","name":"","func":"\nconst heaterC = global.get(\"heaterState\");\n\nif (heaterC === 1){\n msg.payload = \"1\";\n return msg;\n}\nelse{\n msg.payload = \"0\";\n return msg;\n}\n","outputs":1,"noerr":0,"x":690,"y":60,"wires":[["42f3e7ec.29d048","af6b6504.ab4848"]]},{"id":"42f3e7ec.29d048","type":"change","z":"fc826377.b12ce","name":"HeaterState","rules":[{"t":"set","p":"heaterState","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":870,"y":60,"wires":[[]]},{"id":"95edcd7f.efe6c8","type":"function","z":"fc826377.b12ce","name":"","func":"\nconst sprayS = global.get(\"sprayState\");\n\nif (sprayS === 1){\n msg.payload = \"1\";\n return msg;\n}\nelse{\n msg.payload = \"0\";\n return msg;\n}\n","outputs":1,"noerr":0,"x":650,"y":400,"wires":[["7a635c0e.fbfd24","341cf0cc.f3535"]]},{"id":"7a635c0e.fbfd24","type":"change","z":"fc826377.b12ce","name":"HeaterState","rules":[{"t":"set","p":"heaterState","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":830,"y":400,"wires":[[]]},{"id":"f944d751.4c0da8","type":"debug","z":"34243684.8b511a","name":"Mode","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":530,"y":1200,"wires":[]}] |
The Node-RED gets the sensor values, and based on the data, it triggers the GPIO pins connected to Relay.
The amazing processing and controlling features of raspberry pi needs to be fully exploited.
ReplyDeleteYou are right, raspberry pi is an awesome IoT device and it's powerful.
DeleteNode-RED is a visual programming tool that enables users to wire together devices, APIs, and online services to create automations using a browser-based flow editor. It was developed by IBM and is now an open-source project.
DeleteIn industrial automation, Node-RED can be used to control and monitor various systems and devices. For example, Node-RED can be used to connect to PLCs, sensors, and other industrial devices, collect and process data, and then send control commands back to the devices.
Node-RED works by allowing users to create flows, which consist of interconnected nodes. Nodes represent various functionalities, such as reading data from a device, processing the data, and sending control commands. Users can drag and drop nodes from a library and connect them to create a flow that represents the desired automation.
Node-RED's visual interface and support for various communication protocols make it a versatile and user-friendly solution for industrial automation. The platform is also highly scalable, making it suitable for both small and large-scale industrial automation projects.
Hi i don't see the Arduino code on the page ?
ReplyDeletePlease check now. The post has been updated. Thanks
DeleteCan Node-RED be used for real-time control in industrial automation?
ReplyDeleteYes, Node-RED can be used for real-time control in industrial automation. Node-RED provides a visual interface for programming and allows users to easily connect and control different devices and sensors in real-time. The platform also supports various communication protocols such as Modbus, OPC UA, MQTT, and others, which are commonly used in industrial automation for real-time communication between devices. The use of Raspberry Pi, which has a fast and responsive processor, can further enhance the real-time control capabilities of Node-RED in industrial automation applications.
DeleteWhat are some of the benefits of using Node-RED and Raspberry Pi for industrial automation?
ReplyDeleteSome of the benefits of using Node-RED and Raspberry Pi for industrial automation include:
DeleteEase of use: Node-RED provides a visual, drag-and-drop interface for programming, making it easier for non-programmers to create and manage industrial automation solutions.
Low cost: Raspberry Pi is a low-cost and small form factor computer, which makes it an affordable solution for small and medium-sized businesses.
Scalability: Node-RED is a flexible platform that can be easily scaled for both small and large-scale industrial automation systems.
Integration: Node-RED supports various communication protocols and APIs, making it easy to integrate different devices, sensors, and systems into a single automation solution.
Fast development: Node-RED's visual interface and pre-built nodes allow for faster development times compared to traditional programming methods.
Enhanced performance: Raspberry Pi provides fast and responsive performance, making it suitable for real-time control and monitoring applications in industrial automation.
Improved accuracy: Node-RED's visual programming environment and ability to connect different devices and sensors can improve the accuracy of industrial automation systems.
Better reliability: By using Node-RED and Raspberry Pi, industrial automation systems can be made more reliable and efficient, reducing downtime and maintenance costs.
Is it possible to create custom nodes in Node-RED for industrial automation applications?
ReplyDeleteIt is possible to create custom nodes in *Node-RED* for industrial automation applications. Follow the basic steps:
DeleteDetermine the functionality you want to implement in the custom node. This can be anything from interfacing with a specific sensor or controller to implementing a custom algorithm for data processing.
Create a new Node-RED node using the Node.js runtime environment. You can create a new directory in the Node-RED nodes directory (~/.node-red/nodes/) and add a JavaScript file with the appropriate functions.
Define the node's input and output properties. This can include data types, validation rules, and default values.
Implement the node's functionality using JavaScript. You can use existing Node-RED nodes and libraries to implement complex functionality and integrate with external systems.
Test the custom node by deploying it to a Node-RED flow and testing its functionality in a real-world scenario.
Optionally, package the custom node as a Node-RED module and publish it to the Node-RED package repository for others to use.
Creating custom nodes in Node-RED can be a powerful way to extend its functionality for specific industrial automation applications. By leveraging the flexibility and extensibility of Node.js, you can create custom nodes that integrate with a wide range of sensors, controllers, and protocols and automate complex industrial processes.
Post a Comment