Compare inside temp to outside

#1

Let me start by saying that I am very new to node red but not to home automation. I have been using smartthings for the past 2 years but have recently started build my new system (home assistant) for the sole reason of wanting to be independent from the cloud. This brings me to the “simple” project that I am working on or at least I thought it was going to be.

I am trying to set up a flow that would compare the temperature being reported by my outside temperature sensor to the temperature being reported by my room temperature sensor. I am trying to control a whole house exhaust fan in that if the temperature outside is cooler then the temperature inside then the house fan would come on to cool the house down and then of course if the outside temp is greater then turn the fan off.

I tried googling and searching for something close to what I was looking for but kept coming up empty. I hope someone can help

#2

Check this out, consider on the function I have different topic for each sensor

[{"id":"4034a624.c16ec8","type":"function","z":"712ddec8.883c8","name":"salto termico","func":"if (msg.topic == \"/ESP-6/DHT sala/Temperature\") {\n\tcontext.state = msg.payload;\n\n}\nif (msg.topic == \"/ESP-7/BME280/Temperature\") {\n\tcontext.state2 = msg.payload;\n\n}\n\ntemp = (context.state2-context.state);\n\nmsg.payload = parseFloat(temp).toFixed(1);\n\n  return msg;\n\n ","outputs":1,"noerr":0,"x":2730,"y":400,"wires":[["6a634e2e.9a2b3"]]}]
#3

Interesting but not quite what I am looking for … maybe more info from me would help.

I am using diy multi sensors that are reporting back to Home Assistant via mqtt. Each multi sensor is reporting back ( Temperature, Humidity, Motion, and Ambient light). This being the case I figured it would be simpler to pull the “current state” of a sensor from Home Assistant …eg. sensor.outside_temperature and sensor.master_bedroom_temperature … but then I need to be able to compare the 2 values to see if the temperature outside is cooler then inside and if so return a true or false of which I can then use to trigger a switch in Home Assistant.

#4

First, you will need to store one of the temperature readings in the flow context using a change node. Then you can use a switch node to compare the other temperature reading with the previously stored reading and redirect the message accordingly.

#5

You could use the ramp-thermostat.

  1. define a dummy profile
  2. setCurrent for the indoor temperature
  3. setTarget for the outdoor temperature

The output 1 (true or false) can be used to control the fan.
The status will shows you what is going on .

example (you need to install the ramp-thermostat):

[{"id":"cb59eaec.644298","type":"ramp-thermostat","z":"6da90f72.dff58","name":"exhaust fan","profile":"7a5597f.52e6468","hysteresisplus":0,"hysteresisminus":0,"x":430,"y":1940,"wires":[["ddbe4118.bf95f"],[],[]]},{"id":"44f53ec8.66d44","type":"inject","z":"6da90f72.dff58","name":"","topic":"setCurrent","payload":"20","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":200,"y":1880,"wires":[["cb59eaec.644298"]]},{"id":"d1360549.e99e78","type":"inject","z":"6da90f72.dff58","name":"","topic":"setTarget","payload":"18","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":200,"y":1980,"wires":[["cb59eaec.644298"]]},{"id":"ddbe4118.bf95f","type":"debug","z":"6da90f72.dff58","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":650,"y":1940,"wires":[]},{"id":"b84158b7.d33c88","type":"inject","z":"6da90f72.dff58","name":"","topic":"setTarget","payload":"22","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":200,"y":2040,"wires":[["cb59eaec.644298"]]},{"id":"162176e6.ea08b9","type":"comment","z":"6da90f72.dff58","name":"indoor temperature","info":"","x":200,"y":1840,"wires":[]},{"id":"fbd444c6.1a47e8","type":"comment","z":"6da90f72.dff58","name":"outdoot temperature","info":"","x":200,"y":1940,"wires":[]},{"id":"7a5597f.52e6468","type":"profile","z":"","name":"dummy","time1":"00:00","temp1":"20","time2":"24:00","temp2":"20","time3":"","temp3":"","time4":"","temp4":"","time5":"","temp5":"","time6":"","temp6":"","time7":"","temp7":"","time8":"","temp8":"","time9":"","temp9":"","time10":"","temp10":""}]
#6

Another alternative, if you want more complex logic than a comparator with hysteresis, is to use a Join node to get a message containing both values which you can then interrogate and do whatever you want. This example shows just a simple comparator to show the principle. However if do just want a comparator with hysteresis then use the solution from @cflurin.

[{"id":"5d420600.ff6018","type":"inject","z":"6dc690a3.1abc88","name":"","topic":"outside_temp","payload":"14","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":130,"y":1079,"wires":[["320bf519.a5b74a"]]},{"id":"b8dca2bd.7a107","type":"inject","z":"6dc690a3.1abc88","name":"","topic":"outside_temp","payload":"16","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":127,"y":1122,"wires":[["320bf519.a5b74a"]]},{"id":"f80213fe.1fcff8","type":"inject","z":"6dc690a3.1abc88","name":"","topic":"inside_temp","payload":"15","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":130,"y":1213,"wires":[["320bf519.a5b74a"]]},{"id":"320bf519.a5b74a","type":"join","z":"6dc690a3.1abc88","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":true,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":341,"y":1158,"wires":[["ed03ae03.182378"]]},{"id":"c48a6d1b.801948","type":"debug","z":"6dc690a3.1abc88","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":598,"y":1113,"wires":[]},{"id":"ed03ae03.182378","type":"function","z":"6dc690a3.1abc88","name":"Comparatore","func":"// this is passed a payload which is an object with\n// properties outside_temp and inside_temp\nif (msg.payload.outside_temp > msg.payload.inside_temp) {\n    msg.payload = 0;\n} else\n{\n    msg.payload = 1;\n}\nreturn msg;","outputs":1,"noerr":0,"x":517,"y":1179,"wires":[["c48a6d1b.801948"]]}]
#7

Thank you everyone for the help. The one that I think is going to be the most expandable is the one you suggested Colin … below is where I am at with it so far. Once again thank you for all the help

[{"id":"2c1a40f1.61ba98","type":"tab","label":"Summer House Fan Control","disabled":false,"info":"Turn on house fan if inside temperature is hoter then outside temperature"},{"id":"8e8c0b98.78feb","type":"api-current-state","z":"2c1a40f1.61ba98","name":"Master Bedroom Temperature","server":"667f1151.35de1","halt_if":"","override_topic":true,"override_payload":false,"entity_id":"sensor.master_bedroom_temperature","x":165,"y":137,"wires":[["4ff3025b.b7c804","958da5bb.404608"]]},{"id":"506e9c63.9b8734","type":"api-current-state","z":"2c1a40f1.61ba98","name":"Outside Temperature","server":"667f1151.35de1","halt_if":"","override_topic":true,"override_payload":false,"entity_id":"sensor.outside_temperature","x":133,"y":225,"wires":[["4ff3025b.b7c804","aba431c5.28cee8"]],"outputLabels":["outside_temperature"]},{"id":"87d3522d.a3a4e8","type":"inject","z":"2c1a40f1.61ba98","name":"","topic":"","payload":"","payloadType":"date","repeat":"1800","crontab":"","once":true,"onceDelay":"1800","x":101,"y":27,"wires":[["8e8c0b98.78feb","506e9c63.9b8734"]]},{"id":"4ff3025b.b7c804","type":"ui_chart","z":"2c1a40f1.61ba98","name":"","group":"2c2c5905.1e732e","order":0,"width":0,"height":0,"label":"chart","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":"24","removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"colors":["#1f77b4","#ff8000","#00ffff","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"x":326,"y":27,"wires":[[],[]]},{"id":"6039a620.3496d","type":"join","z":"2c1a40f1.61ba98","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":true,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":555,"y":182,"wires":[["edaca9a8.5eb9"]]},{"id":"edaca9a8.5eb9","type":"function","z":"2c1a40f1.61ba98","name":"Comparatore","func":"// this is passed a payload which is an object with\n// properties outside_temp and inside_temp\nif (msg.payload.outside_temp > msg.payload.inside_temp) {\n    msg.payload = 0;\n} else\n{\n    msg.payload = 1;\n}\nreturn msg;","outputs":1,"noerr":0,"x":702,"y":182,"wires":[["c5b81c6e.ec9328"]]},{"id":"aba431c5.28cee8","type":"change","z":"2c1a40f1.61ba98","name":"outside_temp","rules":[{"t":"change","p":"topic","pt":"msg","from":"sensor.outside_temperature","fromt":"str","to":"outside_temp","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":367,"y":225,"wires":[["6039a620.3496d"]]},{"id":"958da5bb.404608","type":"change","z":"2c1a40f1.61ba98","name":"inside_temp","rules":[{"t":"change","p":"topic","pt":"msg","from":"sensor.master_bedroom_temperature","fromt":"str","to":"inside_temp","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":412,"y":137,"wires":[["6039a620.3496d"]]},{"id":"c5b81c6e.ec9328","type":"switch","z":"2c1a40f1.61ba98","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"str"},{"t":"eq","v":"0","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":852,"y":182,"wires":[["6255f066.10c068"],["6ab21977.5ae54"]],"outputLabels":["ON","OFF"]},{"id":"6255f066.10c068","type":"api-call-service","z":"2c1a40f1.61ba98","name":"Fan On","server":"667f1151.35de1","service_domain":"switch","service":"turn_on","data":"{   \"entity_id\": \"switch.master_bedroom_fan_light\" }","mergecontext":"","x":984,"y":124,"wires":[[]]},{"id":"6ab21977.5ae54","type":"api-call-service","z":"2c1a40f1.61ba98","name":"Fan Off","server":"667f1151.35de1","service_domain":"switch","service":"turn_off","data":"{   \"entity_id\": \"switch.master_bedroom_fan_light\" }","mergecontext":"","x":985,"y":233,"wires":[[]]},{"id":"667f1151.35de1","type":"server","z":"","name":"Home Assistant","url":"http://localhost:8123","pass":"aabbmj005"},{"id":"2c2c5905.1e732e","type":"ui_group","z":"","name":"Default","tab":"bb4ed394.51cac","disp":true,"width":"6","collapse":false},{"id":"bb4ed394.51cac","type":"ui_tab","z":"","name":"Temperatures","icon":"dashboard"}]
#8

the flow chart below is what I am eventually shooting for

1 Like
#9

I think you might need hysteresis on some of those tests. Imagine if In and Out are both 70. Sensor readings always have a bit of fluctuation in them so at successive readings you might get In=70.1, Out=70, then at the next reading both are 70.0, and at the next back to 70.1 and 70. That would cause the A/C and or Fan to switch on and off at successive readings, which is probably not a good idea.

#10

I was thinking the same thing … just figured I would post my progress and what my final end point was in case anyone sees a better or more efficient way … any and all suggestion are appreciated

#11

Just to point you towards thinking about the problem at the next level…

Instead of using absolute temperatures as your trigger points, you might like to consider using comfort level instead. Comfort level is a measure of how thermally comfortable an environment is taking into consideration temperature, humidity, air flow, radiant heat, activity level, and clothing.

Have a look at node-red-contrib-comfort for more information.

1 Like
#12

My sensors feed a Temp and Humidity and also does a calculation of “Real Feel” based off of both. The “Real Feel” temperature is the one that I am using. Thank you Dean for the suggestion.

#13

And to make it even more to consider; depending on where you live and the construction of your house, the described method could cause severe damage to your house. In my region (Stockholm, Sweden) and with our house construction, it could be a total disaster to the house to do like described without also calculating the amount of water (can easily be done if you know the temperature & relative humidity) in the outside & inside air before starting the fan. Basically, not replacing the inside air if the outside air holds more water

#14

Hi, I’m almost starting to understand node-red and I couldn’t be more interested in this topic.
My goal is to make a super efficient climate controller that uses intraction and extraction fans, combined wit an AC (when the target temp or humidity could not be reached due to outdoor conditions).
Following a couple of videos I realised I should be using variables to simplify things, and started a very rudimentary flow to tell if the current temperature is higher, lower or equal to target temp… still barebones, but hope it brings new ideas to you, maybe we can get to a solution together :slight_smile:

[{"id":"94542a0e.b713f8","type":"mqtt in","z":"e7cd689b.372498","name":"TEMPin","topic":"clima/THin/temperature","qos":"2","broker":"87de71eb.4a609","x":90,"y":480,"wires":[["e296b3b.2a0a95","5d7095e2.006e7c","ec2ebd7a.eda72","d39c64f0.0174c8"]]},{"id":"1fc1f170.3be2df","type":"mqtt in","z":"e7cd689b.372498","name":"HUMin","topic":"clima/THin/humidity","qos":"2","broker":"87de71eb.4a609","x":120,"y":660,"wires":[["89ec212a.fbd75","5d7095e2.006e7c"]]},{"id":"5d7095e2.006e7c","type":"ui_chart","z":"e7cd689b.372498","name":"","group":"185c8e21.2d6b42","order":0,"width":0,"height":0,"label":"24H","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":["#e20e0e","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"x":310,"y":720,"wires":[[],[]]},{"id":"e296b3b.2a0a95","type":"ui_text","z":"e7cd689b.372498","group":"185c8e21.2d6b42","order":0,"width":0,"height":0,"name":"","label":"TEMPERATURA IN","format":"{{msg.payload}} ºC","layout":"col-center","x":390,"y":620,"wires":[]},{"id":"89ec212a.fbd75","type":"ui_text","z":"e7cd689b.372498","group":"185c8e21.2d6b42","order":0,"width":0,"height":0,"name":"","label":"HUMEDAD IN","format":"{{msg.payload}} %","layout":"col-center","x":380,"y":660,"wires":[]},{"id":"ec2ebd7a.eda72","type":"switch","z":"e7cd689b.372498","name":"testswitch target","property":"payload","propertyType":"msg","rules":[{"t":"lt","v":"targettemp","vt":"global"},{"t":"eq","v":"targettemp","vt":"global"},{"t":"gt","v":"targettemp","vt":"global"}],"checkall":"true","repair":false,"outputs":3,"x":260,"y":480,"wires":[["dc62e15a.a5e07"],["155034ca.efbb1b"],["cd8a1a01.1b5058"]]},{"id":"d39c64f0.0174c8","type":"change","z":"e7cd689b.372498","name":"declara global","rules":[{"t":"set","p":"thin1temp","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":280,"y":400,"wires":[[]]},{"id":"14b5ccd7.3667d3","type":"debug","z":"e7cd689b.372498","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":750,"y":560,"wires":[]},{"id":"1452d44b.a94d0c","type":"inject","z":"e7cd689b.372498","name":"Input target temp","topic":"","payload":"22","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":740,"y":480,"wires":[["14b5ccd7.3667d3","9239460b.c9da38"]]},{"id":"9239460b.c9da38","type":"change","z":"e7cd689b.372498","name":"declara global","rules":[{"t":"set","p":"targettemp","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":760,"y":420,"wires":[[]]},{"id":"dc62e15a.a5e07","type":"change","z":"e7cd689b.372498","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"low temp","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":460,"y":440,"wires":[["14b5ccd7.3667d3"]]},{"id":"155034ca.efbb1b","type":"change","z":"e7cd689b.372498","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"good temp","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":460,"y":480,"wires":[["14b5ccd7.3667d3"]]},{"id":"cd8a1a01.1b5058","type":"change","z":"e7cd689b.372498","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"high temp","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":460,"y":520,"wires":[["14b5ccd7.3667d3"]]},{"id":"87de71eb.4a609","type":"mqtt-broker","z":"","name":"mosquitto","broker":"192.168.1.200","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"MQTTinfo/mosquitto","birthQos":"2","birthPayload":"Mosquitto is up and runnig!!!","willTopic":"MQTTinfo/mosquitto","willQos":"2","willPayload":"Mosquitto is down!!!!"},{"id":"185c8e21.2d6b42","type":"ui_group","z":"","name":"CLIMA","tab":"fb9e7d3d.87629","disp":true,"width":"6","collapse":false},{"id":"fb9e7d3d.87629","type":"ui_tab","z":"","name":"DEV","icon":"dashboard"}]
#15

This is a Node Red use case that pops up quite regularly. There was an in-depth discussion about the complexities of climate control on the old Google Groups list late last year

3 Likes
#16

Any time you want to post some code, please put separate lines before and after the text that contain just 3 backticks (like ```)

This will create a code block that has proper formatting, and avoids having your double quotes become “smart quotes”, which are not valid JSON. This makes it easier for us to copy/paste your code into our own environments.

Fell free to edit your previous post – and you can check out this discussion for even more tips.

1 Like
#17

Thank you, and sorry for that. I didn’t know how to do it, that was my first post here.

#18

@nmatt25 when it comes to rules, you can try node-red-contrib-norelite. There are some examples:

It may be helpful to you.

1 Like
#19

Thank you, I’ll have a look at it. I tried the RAMP thermostat but didn’t like it. Right now I’m trying to make my own by using Switch and Change nodes to compare global variables, but norelite looks much easier :slight_smile:

[{"id":"a5a73581.054de8","type":"tab","label":"DIY thermostat","disabled":false,"info":""},{"id":"d2d67575.2331b8","type":"mqtt in","z":"a5a73581.054de8","name":"TEMPin","topic":"clima/THin/temperature","qos":"2","broker":"87de71eb.4a609","x":70,"y":580,"wires":[["c01839cf.3c67a8","a346eee7.ced05"]]},{"id":"93e7988e.5ca618","type":"mqtt in","z":"a5a73581.054de8","name":"HUMin","topic":"clima/THin/humidity","qos":"2","broker":"87de71eb.4a609","x":150,"y":740,"wires":[[]]},{"id":"c01839cf.3c67a8","type":"switch","z":"a5a73581.054de8","name":"compare current vs target","property":"payload","propertyType":"msg","rules":[{"t":"lte","v":"minTargettemp","vt":"global"},{"t":"btwn","v":"minTargettemp","vt":"global","v2":"maxTargettemp","v2t":"global"},{"t":"gte","v":"maxTargettemp","vt":"global"}],"checkall":"true","repair":false,"outputs":3,"x":310,"y":580,"wires":[["26da2bbe.095034"],["87e9dfd1.674d"],["81e13fbd.fefb1"]]},{"id":"a346eee7.ced05","type":"change","z":"a5a73581.054de8","name":"declara global","rules":[{"t":"set","p":"thin1temp","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":380,"y":500,"wires":[[]]},{"id":"80348693.453638","type":"inject","z":"a5a73581.054de8","name":"mintarget","topic":"","payload":"22","payloadType":"str","repeat":"1","crontab":"","once":true,"onceDelay":0.1,"x":270,"y":360,"wires":[["87d0f447.858f98"]]},{"id":"87d0f447.858f98","type":"change","z":"a5a73581.054de8","name":"minTargettemp","rules":[{"t":"set","p":"minTargettemp","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":520,"y":360,"wires":[[]]},{"id":"26da2bbe.095034","type":"change","z":"a5a73581.054de8","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"LOW","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":550,"y":540,"wires":[["ef919ea.9b3726"]]},{"id":"87e9dfd1.674d","type":"change","z":"a5a73581.054de8","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"OK","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":550,"y":580,"wires":[["ef919ea.9b3726"]]},{"id":"81e13fbd.fefb1","type":"change","z":"a5a73581.054de8","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"HIGH","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":550,"y":620,"wires":[["ef919ea.9b3726"]]},{"id":"5c119931.016448","type":"change","z":"a5a73581.054de8","name":"maxTargettemp","rules":[{"t":"set","p":"maxTargettemp","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":520,"y":400,"wires":[[]]},{"id":"406d2664.918018","type":"inject","z":"a5a73581.054de8","name":"maxTarget","topic":"","payload":"23","payloadType":"str","repeat":"1","crontab":"","once":true,"onceDelay":0.1,"x":270,"y":400,"wires":[["5c119931.016448"]]},{"id":"ef919ea.9b3726","type":"change","z":"a5a73581.054de8","name":"","rules":[{"t":"set","p":"inTempStatus","pt":"global","to":"topic","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":790,"y":580,"wires":[["df252ca9.98e16","8d3e078b.08d498"]]},{"id":"df252ca9.98e16","type":"template","z":"a5a73581.054de8","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"The IN temperature is {{topic}} and equals to {{payload}} ","output":"str","x":740,"y":660,"wires":[["4dc60ad1.15c3c4"]]},{"id":"f43e1241.aca98","type":"ui_toast","z":"a5a73581.054de8","position":"top right","displayTime":"2","highlight":"","outputs":0,"ok":"OK","cancel":"","topic":"","name":"","x":1200,"y":660,"wires":[]},{"id":"4dc60ad1.15c3c4","type":"rbe","z":"a5a73581.054de8","name":"","func":"rbe","gap":"","start":"","inout":"out","property":"payload","x":930,"y":660,"wires":[["f43e1241.aca98"]]},{"id":"8d3e078b.08d498","type":"ui_text","z":"a5a73581.054de8","group":"185c8e21.2d6b42","order":0,"width":0,"height":0,"name":"","label":"TEMPERATURE IN:","format":"{{msg.topic}}: {{msg.payload}}ºC","layout":"col-center","x":1100,"y":580,"wires":[]},{"id":"87de71eb.4a609","type":"mqtt-broker","z":"","name":"mosquitto","broker":"192.168.1.200","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"MQTTinfo/mosquitto","birthQos":"2","birthPayload":"Mosquitto is up and runnig!!!","willTopic":"MQTTinfo/mosquitto","willQos":"2","willPayload":"Mosquitto is down!!!!"},{"id":"185c8e21.2d6b42","type":"ui_group","z":"","name":"CLIMA","tab":"fb9e7d3d.87629","disp":true,"width":"6","collapse":false},{"id":"fb9e7d3d.87629","type":"ui_tab","z":"","name":"DEV","icon":"dashboard"}]

Work in progress!

#20

UPDATE:
I didn’t understand very well how to use norelite rules, so I’m trying to follow with the default nodes…
I just discovered how to add msg properties and payloads are starting to get messy, as well as variables (most of them are global)…
I documented it a bit to let others figure what I’m trying to do on each branch of the flow.

[{"id":"a5a73581.054de8","type":"tab","label":"DIY thermostat","disabled":false,"info":""},{"id":"d2d67575.2331b8","type":"mqtt in","z":"a5a73581.054de8","name":"TEMPin","topic":"clima/THin/temperature","qos":"2","broker":"87de71eb.4a609","x":70,"y":560,"wires":[["d6ab6019.3fe7c","a346eee7.ced05"]]},{"id":"93e7988e.5ca618","type":"mqtt in","z":"a5a73581.054de8","name":"HUMIDITY in","topic":"clima/THin/humidity","qos":"2","broker":"87de71eb.4a609","x":110,"y":1140,"wires":[[]]},{"id":"c01839cf.3c67a8","type":"switch","z":"a5a73581.054de8","name":"compare current vs target","property":"payload","propertyType":"msg","rules":[{"t":"lte","v":"minTargettemp","vt":"global"},{"t":"btwn","v":"minTargettemp","vt":"global","v2":"maxTargettemp","v2t":"global"},{"t":"gte","v":"maxTargettemp","vt":"global"}],"checkall":"true","repair":false,"outputs":3,"x":510,"y":560,"wires":[["26da2bbe.095034"],["87e9dfd1.674d"],["81e13fbd.fefb1"]]},{"id":"a346eee7.ced05","type":"change","z":"a5a73581.054de8","name":"Make global and enrich","rules":[{"t":"set","p":"inCurrentTemp","pt":"global","to":"payload","tot":"msg"},{"t":"set","p":"currentIN","pt":"msg","to":"payload","tot":"msg"},{"t":"set","p":"currentOUT","pt":"msg","to":"outCurrentTemp","tot":"global"}],"action":"","property":"","from":"","to":"","reg":false,"x":270,"y":560,"wires":[["c01839cf.3c67a8"]]},{"id":"80348693.453638","type":"inject","z":"a5a73581.054de8","name":"mintarget","topic":"","payload":"22","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":260,"y":140,"wires":[["d9f3a6f4.772808"]]},{"id":"87d0f447.858f98","type":"change","z":"a5a73581.054de8","name":"minTargettemp","rules":[{"t":"set","p":"minTargettemp","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":640,"y":140,"wires":[[]]},{"id":"26da2bbe.095034","type":"change","z":"a5a73581.054de8","name":"low","rules":[{"t":"set","p":"insideStatus","pt":"msg","to":"LOW","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":710,"y":500,"wires":[["ef919ea.9b3726"]]},{"id":"87e9dfd1.674d","type":"change","z":"a5a73581.054de8","name":"ok","rules":[{"t":"set","p":"insideStatus","pt":"msg","to":"OK","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":710,"y":560,"wires":[["ef919ea.9b3726"]]},{"id":"81e13fbd.fefb1","type":"change","z":"a5a73581.054de8","name":"high","rules":[{"t":"set","p":"insideStatus","pt":"msg","to":"HIGH","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":710,"y":620,"wires":[["ef919ea.9b3726"]]},{"id":"5c119931.016448","type":"change","z":"a5a73581.054de8","name":"maxTargettemp","rules":[{"t":"set","p":"maxTargettemp","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":640,"y":180,"wires":[[]]},{"id":"406d2664.918018","type":"inject","z":"a5a73581.054de8","name":"maxTarget","topic":"","payload":"23","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":260,"y":180,"wires":[["ced68327.57f07"]]},{"id":"ef919ea.9b3726","type":"change","z":"a5a73581.054de8","name":"","rules":[{"t":"set","p":"inTempStatus","pt":"global","to":"insideStatus","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1110,"y":420,"wires":[["df252ca9.98e16","8d3e078b.08d498"]]},{"id":"df252ca9.98e16","type":"template","z":"a5a73581.054de8","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"The IN temperature is {{insideState}} and equals to {{payload}} ","output":"str","x":1060,"y":480,"wires":[["4dc60ad1.15c3c4"]]},{"id":"f43e1241.aca98","type":"ui_toast","z":"a5a73581.054de8","position":"top right","displayTime":"2","highlight":"","outputs":0,"ok":"OK","cancel":"","topic":"","name":"","x":1390,"y":480,"wires":[]},{"id":"4dc60ad1.15c3c4","type":"rbe","z":"a5a73581.054de8","name":"","func":"rbe","gap":"","start":"","inout":"out","property":"payload","x":1190,"y":480,"wires":[["f43e1241.aca98"]]},{"id":"8d3e078b.08d498","type":"ui_text","z":"a5a73581.054de8","group":"185c8e21.2d6b42","order":3,"width":0,"height":0,"name":"","label":"TEMPERATURA IN:","format":"{{msg.payload}}ºC  {{msg.insideStatus}}","layout":"col-center","x":1400,"y":420,"wires":[]},{"id":"d6ab6019.3fe7c","type":"switch","z":"a5a73581.054de8","name":"max&min switch","property":"payload","propertyType":"msg","rules":[{"t":"gt","v":"maxINrecTemp","vt":"global"},{"t":"lt","v":"minINrecTemp","vt":"global"}],"checkall":"true","repair":false,"outputs":2,"x":180,"y":340,"wires":[["dacc9d76.9d8b4"],["30674aec.586096"]]},{"id":"dacc9d76.9d8b4","type":"change","z":"a5a73581.054de8","name":"","rules":[{"t":"set","p":"maxINrecTemp","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":430,"y":320,"wires":[["79ff3914.549568"]]},{"id":"30674aec.586096","type":"change","z":"a5a73581.054de8","name":"","rules":[{"t":"set","p":"minINrecTemp","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":430,"y":360,"wires":[["35604e55.3982d2"]]},{"id":"1a69a63d.dc689a","type":"ui_button","z":"a5a73581.054de8","name":"","group":"185c8e21.2d6b42","order":9,"width":"0","height":"0","passthru":false,"label":"RESET max&min","color":"","bgcolor":"#FF0000","icon":"","payload":"inCurrentTemp","payloadType":"global","topic":"","x":170,"y":300,"wires":[["30674aec.586096","dacc9d76.9d8b4"]]},{"id":"79ff3914.549568","type":"ui_text","z":"a5a73581.054de8","group":"185c8e21.2d6b42","order":7,"width":0,"height":0,"name":"","label":"TEMP MAX:","format":"{{msg.payload}}ºC","layout":"row-left","x":630,"y":320,"wires":[]},{"id":"35604e55.3982d2","type":"ui_text","z":"a5a73581.054de8","group":"185c8e21.2d6b42","order":8,"width":0,"height":0,"name":"","label":"TEMP MIN:","format":"{{msg.payload}}ºC","layout":"row-left","x":630,"y":360,"wires":[]},{"id":"d9f3a6f4.772808","type":"ui_text_input","z":"a5a73581.054de8","name":"","label":"Target MIN temp","group":"185c8e21.2d6b42","order":10,"width":0,"height":0,"passthru":true,"mode":"number","delay":"30","topic":"","x":460,"y":140,"wires":[["87d0f447.858f98"]]},{"id":"ced68327.57f07","type":"ui_text_input","z":"a5a73581.054de8","name":"","label":"Target MAX temp","group":"185c8e21.2d6b42","order":11,"width":0,"height":0,"passthru":true,"mode":"number","delay":"30","topic":"","x":450,"y":180,"wires":[["5c119931.016448"]]},{"id":"4088488d.872998","type":"comment","z":"a5a73581.054de8","name":"Set HYSTERESIS","info":"In order to recreate some HYSTERESIS my solution is\nto set MAX & MIN target temperatures, \nleaving a \"comfort zone\" between them to prevent oscillation.","x":130,"y":100,"wires":[]},{"id":"3b73181e.b27118","type":"comment","z":"a5a73581.054de8","name":"HIGHEST & LOWEST TEMPERATURES","info":"This part of the flow stores and displays in the UI\nthe HIGH and LOW temperatures as well as\nthe RESET button, when pressed sets both MAX & MIN\nas the current temperature.\n\nTO DO: \n-Add the time of the highest and lowest\n-Log it propperly?","x":160,"y":260,"wires":[]},{"id":"f7e5aa0a.05f0a8","type":"comment","z":"a5a73581.054de8","name":"OUTSIDE TEMPERATURE INPUT","info":"","x":160,"y":740,"wires":[]},{"id":"3b3eb4dc.b7b3ec","type":"inject","z":"a5a73581.054de8","name":"","topic":"","payload":"28","payloadType":"str","repeat":"10","crontab":"","once":false,"onceDelay":0.1,"x":110,"y":780,"wires":[["20358370.b39f8c"]]},{"id":"20358370.b39f8c","type":"switch","z":"a5a73581.054de8","name":"compare out current vs out limit","property":"payload","propertyType":"msg","rules":[{"t":"lt","v":"outLimitTemp","vt":"flow"},{"t":"eq","v":"outLimitTemp","vt":"flow"},{"t":"gt","v":"outLimitTemp","vt":"flow"}],"checkall":"true","repair":false,"outputs":3,"x":510,"y":820,"wires":[["7ae223d7.f0513c"],["c4a296a7.39d7f8"],["dccb88d1.b21668"]]},{"id":"7ae223d7.f0513c","type":"change","z":"a5a73581.054de8","name":"LOW","rules":[{"t":"set","p":"outsideStatus","pt":"msg","to":"LOW","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":730,"y":760,"wires":[["d39906b3.8124e8"]]},{"id":"c4a296a7.39d7f8","type":"change","z":"a5a73581.054de8","name":"LIMIT REACHED","rules":[{"t":"set","p":"outsideStatus","pt":"msg","to":"LIMIT REACHED","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":770,"y":820,"wires":[["d39906b3.8124e8"]]},{"id":"dccb88d1.b21668","type":"change","z":"a5a73581.054de8","name":"HELL MODE","rules":[{"t":"set","p":"outsideStatus","pt":"msg","to":"HELL MODE","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":750,"y":880,"wires":[["d39906b3.8124e8"]]},{"id":"d39906b3.8124e8","type":"change","z":"a5a73581.054de8","name":"Current OUT made global","rules":[{"t":"set","p":"outCurrentTemp","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1090,"y":800,"wires":[["20f9ce42.7a56e2"]]},{"id":"ab54e0cd.c38c1","type":"change","z":"a5a73581.054de8","name":"out limit temp made flow","rules":[{"t":"set","p":"outLimitTemp","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":550,"y":60,"wires":[[]]},{"id":"57dec835.e186a8","type":"inject","z":"a5a73581.054de8","name":"","topic":"","payload":"28,5","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":350,"y":60,"wires":[["ab54e0cd.c38c1"]]},{"id":"1f9e9eb0.d68fa1","type":"ui_switch","z":"a5a73581.054de8","name":"","label":"extractor","group":"185c8e21.2d6b42","order":0,"width":0,"height":0,"passthru":false,"decouple":"true","topic":"","style":"","onvalue":"1","onvalueType":"num","onicon":"","oncolor":"","offvalue":"0","offvalueType":"num","officon":"","offcolor":"","x":1920,"y":680,"wires":[[]]},{"id":"fade8ab5.865f38","type":"ui_switch","z":"a5a73581.054de8","name":"","label":"intractor","group":"185c8e21.2d6b42","order":0,"width":0,"height":0,"passthru":false,"decouple":"true","topic":"","style":"","onvalue":"1","onvalueType":"num","onicon":"","oncolor":"","offvalue":"0","offvalueType":"num","officon":"","offcolor":"","x":1920,"y":720,"wires":[[]]},{"id":"7a1c0b06.250124","type":"ui_switch","z":"a5a73581.054de8","name":"","label":"aircon","group":"185c8e21.2d6b42","order":0,"width":0,"height":0,"passthru":false,"decouple":"true","topic":"","style":"","onvalue":"1","onvalueType":"num","onicon":"","oncolor":"","offvalue":"0","offvalueType":"num","officon":"","offcolor":"","x":1910,"y":760,"wires":[[]]},{"id":"c004ca01.283ea8","type":"comment","z":"a5a73581.054de8","name":"Set OUT LIMIT TEMPERATURE","info":"The max outside temperature acceptable.\nHigher values mean that we can't get to \nthe target temperature by air exchange.\nIf outside temp raises above this point,\nHELL MODE will turn on:\nturning OFF the intractor, ON the AC, \nand after some minutes, turn OFF the extractor","x":170,"y":20,"wires":[]},{"id":"22362af5.b1e326","type":"inject","z":"a5a73581.054de8","name":"","topic":"","payload":"outCurrentTemp","payloadType":"global","repeat":"5","crontab":"","once":false,"onceDelay":0.1,"x":190,"y":900,"wires":[[]]},{"id":"20f9ce42.7a56e2","type":"debug","z":"a5a73581.054de8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":1330,"y":820,"wires":[]},{"id":"f81862e9.90f52","type":"comment","z":"a5a73581.054de8","name":"TO DO....","info":"WORK IN PROGRESS....","x":100,"y":1100,"wires":[]},{"id":"9b3867d8.2cb508","type":"comment","z":"a5a73581.054de8","name":"Dummies","info":"Theese are the representation of \nwhat we want to trigger with our thermostat.... \nBy the momment...(until we add humidity control, \nbut let's make it work first XD )","x":1920,"y":640,"wires":[]},{"id":"c5044936.9bdd38","type":"comment","z":"a5a73581.054de8","name":"INSIDE TEMPERATURE INPUT","info":"","x":130,"y":520,"wires":[]},{"id":"fff9761c.210468","type":"comment","z":"a5a73581.054de8","name":"WORK IN PROGRESS OVER HERE...","info":"","x":990,"y":720,"wires":[]},{"id":"60d7aa0a.552cb4","type":"comment","z":"a5a73581.054de8","name":"WORK IN PROGRESS OVER HERE...","info":"","x":1030,"y":580,"wires":[]},{"id":"fd6529ce.ff6b68","type":"comment","z":"a5a73581.054de8","name":"WORK IN PROGRESS OVER HERE...","info":"","x":1390,"y":560,"wires":[]},{"id":"87de71eb.4a609","type":"mqtt-broker","z":"","name":"mosquitto","broker":"192.168.1.200","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"MQTTinfo/mosquitto","birthQos":"2","birthPayload":"Mosquitto is up and runnig!!!","willTopic":"MQTTinfo/mosquitto","willQos":"2","willPayload":"Mosquitto is down!!!!"},{"id":"185c8e21.2d6b42","type":"ui_group","z":"","name":"CLIMA","tab":"fb9e7d3d.87629","disp":true,"width":"6","collapse":false},{"id":"fb9e7d3d.87629","type":"ui_tab","z":"","name":"DEV","icon":"dashboard"}]
``