Switching ON/OFF Heat Pump based on Inside Temp

1,046 views
Skip to first unread message

Ventsislav Gyondrov

unread,
Mar 11, 2018, 7:29:08 PM3/11/18
to Node-RED


I hava a simple flow that monitors energy consumption of my heat pump using a smart switch and it is sending the values to emoncms.org
screensave

and here is the output:
screensave

I find it difficult to construct function/flow that monitors the temperature and switches the switch ON and OFF based on value .What makes even more difficult is that the temperature is changing frequently
here is what I would like
if temperature <21 (for at least 5min ) switch on
if temperature >22 (for at least 5min ) switch off

and then post it to the device

screensave

Would Be Greatly Appreciated If Anyone Can Help Me

Auto Generated Inline Image 1
Auto Generated Inline Image 2
Auto Generated Inline Image 3

AIOT MAKER

unread,
Mar 12, 2018, 2:27:11 AM3/12/18
to Node-RED
Hello,

Here is a proposed engine for commanding the switching. 

How it works: There is a trigger node to manage temperature below 21 degrees and another trigger node to manage temperatures above 22 degrees Celsius. The trigger node will start a timeout counting whenever it receives a message coming from the switch node. When the timeout expires (meaning the temperature remained too high or too low for 5 minutes)  the trigger node it will send the msg downstream to command the switch (ON or OFF). The timeout will be cleared in case the temperature changes back to the range 21-22 degrees.

Notes:
1- I configured the timeout in the trigger nodes for  5 seconds to speed up the testing so please change the nodes config to comply with the 5 minutes requirement
2- It is missing to create the http request to POST the command to the device. 
3- This flow should be a branch of your flow (connected to the http node)
4- Of course it is necessary to remove the inject nodes as they are in the proposed flow only for testing purposes





Testing flow:

[{"id":"69fce963.a50ed8","type":"switch","z":"3ff0ea88.9ac796","name":"","property":"payload.Temperature","propertyType":"msg","rules":[{"t":"gte","v":"21","vt":"num"},{"t":"lt","v":"21","vt":"str"},{"t":"gt","v":"22","vt":"num"},{"t":"lte","v":"22","vt":"str"}],"checkall":"true","outputs":4,"x":330,"y":200,"wires":[["5f1a5bd3.0c5944"],["f38982a1.141f9"],["dc74af0.699825"],["1bd19aa4.919b35"]]},{"id":"ebb7513.409e3b","type":"inject","z":"3ff0ea88.9ac796","name":"Low 18","topic":"","payload":"{\"Temperature\":18}","payloadType":"json","repeat":"","crontab":"","once":false,"x":130,"y":140,"wires":[["69fce963.a50ed8"]]},{"id":"7652473b.d257c8","type":"inject","z":"3ff0ea88.9ac796","name":"Good 21.5","topic":"","payload":"{\"Temperature\":21.5}","payloadType":"json","repeat":"","crontab":"","once":false,"x":120,"y":200,"wires":[["69fce963.a50ed8"]]},{"id":"f2a7154f.58be68","type":"inject","z":"3ff0ea88.9ac796","name":"High 23","topic":"","payload":"{     \"Temperature\": 23 }","payloadType":"json","repeat":"","crontab":"","once":false,"x":130,"y":260,"wires":[["69fce963.a50ed8"]]},{"id":"43a7483e.056dd8","type":"debug","z":"3ff0ea88.9ac796","name":"Replace by HTTP node","active":true,"console":"false","complete":"true","x":890,"y":180,"wires":[]},{"id":"84c29a18.3a1a98","type":"debug","z":"3ff0ea88.9ac796","name":"Replace by HTTP node","active":true,"console":"false","complete":"true","x":890,"y":240,"wires":[]},{"id":"f38982a1.141f9","type":"trigger","z":"3ff0ea88.9ac796","op1":"","op2":"","op1type":"nul","op2type":"pay","duration":"5","extend":false,"units":"s","reset":"stop low","name":"Activate Low","x":650,"y":180,"wires":[["43a7483e.056dd8"]]},{"id":"dc74af0.699825","type":"trigger","z":"3ff0ea88.9ac796","op1":"","op2":"","op1type":"nul","op2type":"pay","duration":"5","extend":false,"units":"s","reset":"stop high","name":"Activate High","x":650,"y":240,"wires":[["84c29a18.3a1a98"]]},{"id":"5f1a5bd3.0c5944","type":"change","z":"3ff0ea88.9ac796","name":"Stop Low","rules":[{"t":"set","p":"payload","pt":"msg","to":"stop low","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":460,"y":140,"wires":[["f38982a1.141f9"]]},{"id":"1bd19aa4.919b35","type":"change","z":"3ff0ea88.9ac796","name":"Stop High","rules":[{"t":"set","p":"payload","pt":"msg","to":"stop high","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":460,"y":280,"wires":[["dc74af0.699825"]]}]


Ventsislav Gyondrov

unread,
Mar 12, 2018, 9:42:37 AM3/12/18
to Node-RED
Hi AIOT MAKER

thank you so much for taking the time to help me. I really appreciate it.


cflurin

unread,
Mar 12, 2018, 9:49:30 AM3/12/18
to Node-RED
Did you consider using the contrib-ramp-thermostat node. It has a hysteresis setting.
If necessary, you can add a trigger for the 5min delay.

Colin Law

unread,
Mar 12, 2018, 9:56:16 AM3/12/18
to node...@googlegroups.com
node-red-contrib-ramp-thermostat is indeed quite a useful node. It is
unfortunate that the author mixed up the two areas of temperature
profile generation and that of a thermostat with hysteresis. I think
it would have been much better as two separate nodes.

@Ventsislav if what you are actually doing is controlling the
temperature of something (a room for example) then you might like to
consider using node-red-contrib-pid along with
node-red-contrib-timeprop. That way you should be able to get much
better control than with a thermostat, if that is important.

Colin
> --
> http://nodered.org
>
> Join us on Slack to continue the conversation: http://nodered.org/slack
> ---
> You received this message because you are subscribed to the Google Groups
> "Node-RED" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to node-red+u...@googlegroups.com.
> To post to this group, send email to node...@googlegroups.com.
> Visit this group at https://groups.google.com/group/node-red.
> To view this discussion on the web, visit
> https://groups.google.com/d/msgid/node-red/d6e0e670-1857-4fa7-9b9f-e7c3c70e7389%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.

cflurin

unread,
Mar 12, 2018, 10:06:02 AM3/12/18
to Node-RED

On Monday, March 12, 2018 at 2:56:16 PM UTC+1, Colin Law wrote:
node-red-contrib-ramp-thermostat is indeed quite a useful node. It is
unfortunate that the author mixed up the two areas of temperature
profile generation and that of a thermostat with hysteresis.  I think
it would have been much better as two separate nodes.



Well that is your opinion, actually I added the hysteresis on request from users :-)

Colin Law

unread,
Mar 12, 2018, 10:25:45 AM3/12/18
to node...@googlegroups.com
Yes, that is my opinion, that is why I said "I think ...". It is not
the hysteresis that is the issue, it is the thermostat in the same
node as the profiling. I use it for generating ramps for other
purposes and it is excellent at that. Having the thermostat built in
just makes it a bit confusing to use. Similarly if one just wants a
thermostat with a fixed or adjustable setpoint then the ramp facility
confuses the situation. A separate ramp node that one could feed into
a thermostat node (or whatever) would be simpler for the user. Again
all in my opinion, which is often at variance with others' of course.

Colin

>
> --
> http://nodered.org
>
> Join us on Slack to continue the conversation: http://nodered.org/slack
> ---
> You received this message because you are subscribed to the Google Groups
> "Node-RED" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to node-red+u...@googlegroups.com.
> To post to this group, send email to node...@googlegroups.com.
> Visit this group at https://groups.google.com/group/node-red.
> To view this discussion on the web, visit
> https://groups.google.com/d/msgid/node-red/e183c8fc-d35f-4770-9eb0-7da6667c0b33%40googlegroups.com.

Walter Kraembring

unread,
Mar 12, 2018, 1:28:03 PM3/12/18
to Node-RED
Since you are reading the temperature frequently (every 10 second?) you should maybe also consider using the Smooth node to create a reasonable average

Ventsislav Gyondrov

unread,
Mar 12, 2018, 1:55:47 PM3/12/18
to Node-RED
I will try to explain what I'm trying to accomplish.with
My heat pump is set at 23 C room temp and you would expect to switch on when is below that and to switch off when is above, but that is not the case (Mitsubishi guys know better)
the red line is temp measured 50cm (20in) above the floor, so at approx 2m where the Air Con(heat pump) is installed must be higher.
As you can see it is doing at least 6 on/off cycles an hour (which I think is a bit too much, given room temp is above 23.5)

All I want is to stay off while the room temp is above 22-23 C and off if it is below 21 C like that:

That's all

Thank you:
AIOT MAKER
cflurin
Colin Law

for your suggestions

Colin Law

unread,
Mar 12, 2018, 4:39:27 PM3/12/18
to node...@googlegroups.com
As cflurin suggested the ramp-thermostat mode can do that (just ignore the ramp part of it and use the thermostat) with appropriate hysteresis to give you the gap you want.  If your process measurement is particularly noisy then as Walter suggested you can use a Smooth node to average out the readings before passing them to the thermostat.

Colin

--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+unsubscribe@googlegroups.com.

To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.

Dean Cording

unread,
Mar 13, 2018, 5:47:02 AM3/13/18
to Node-RED
There was a big conversation about this on this list a couple of months ago where we went into PID controls, comfort levels, and heater controls.

Have a read through 





Dean

Ventsislav Gyondrov

unread,
Mar 14, 2018, 6:36:23 PM3/14/18
to Node-RED
I thought I had it all figured out until Power outage when the wall plug switch defaulted to ON and then the flow I was using became useless.So I am back here relying on your kindness :)
I have tried to implement something between what Walter Kraembring and AIOT MAKER suggested but I guess I need to check what the current status of the wall plug switch is and then proceed further.
I am currently using Fred and ramp-thermostat can't be installed but the example with it would be nice as I may consider moving the flow to my Pi
So Here is my current flow:

[{"id":"e47893eb.402fa","type":"inject","z":"c05a9503.0c154","name":"18","topic":"","payload":"{\"Id\":\"ID\",\"Name\":\"AirConditioner( MITSUBISHI ELECTRIC MSZ-FH25VE)\",\"Serial\":\"Serial\",\"DeviceEnergyType\":1,\"FamilyType\":1,\"ActivePower\":0.00068,\"ActivePowerUnit\":\"kW\",\"CounterReading\":1632.542,\"CounterReadingUnit\":\"kWh\",\"CounterReadingT1\":1632.542,\"SwitchOn\":true,\"Voltage\":248.9,\"VoltageL1\":248.9,\"Current\":0.022,\"PowerFactor\":0.123,\"PowerFactorL1\":0.123,\"Temperature\":18,\"ValueDate\":\"2018-03-14T16:36:33.416476\"}","payloadType":"json","repeat":"","crontab":"","once":false,"x":110,"y":540,"wires":[["ba3e2c9.e64ccd"]]},{"id":"688395ea.7cccdc","type":"debug","z":"c05a9503.0c154","name":"","active":true,"console":"false","complete":"true","x":890,"y":780,"wires":[]},{"id":"de514b92.b47b78","type":"debug","z":"c05a9503.0c154","name":"","active":true,"console":"false","complete":"true","x":890,"y":720,"wires":[]},{"id":"34f18912.1aaca6","type":"inject","z":"c05a9503.0c154","name":"21.5","topic":"","payload":"{\"Id\":\"ID\",\"Name\":\"AirConditioner( MITSUBISHI ELECTRIC MSZ-FH25VE)\",\"Serial\":\"Serial\",\"DeviceEnergyType\":1,\"FamilyType\":1,\"ActivePower\":0.00068,\"ActivePowerUnit\":\"kW\",\"CounterReading\":1632.542,\"CounterReadingUnit\":\"kWh\",\"CounterReadingT1\":1632.542,\"SwitchOn\":true,\"Voltage\":248.9,\"VoltageL1\":248.9,\"Current\":0.022,\"PowerFactor\":0.123,\"PowerFactorL1\":0.123,\"Temperature\":21.5,\"ValueDate\":\"2018-03-14T16:36:33.416476\"}","payloadType":"json","repeat":"","crontab":"","once":false,"x":110,"y":580,"wires":[["ba3e2c9.e64ccd"]]},{"id":"953da161.fa063","type":"inject","z":"c05a9503.0c154","name":"23","topic":"","payload":"{\"Id\":\"ID\",\"Name\":\"AirConditioner( MITSUBISHI ELECTRIC MSZ-FH25VE)\",\"Serial\":\"Serial\",\"DeviceEnergyType\":1,\"FamilyType\":1,\"ActivePower\":0.00068,\"ActivePowerUnit\":\"kW\",\"CounterReading\":1632.542,\"CounterReadingUnit\":\"kWh\",\"CounterReadingT1\":1632.542,\"SwitchOn\":true,\"Voltage\":248.9,\"VoltageL1\":248.9,\"Current\":0.022,\"PowerFactor\":0.123,\"PowerFactorL1\":0.123,\"Temperature\":23,\"ValueDate\":\"2018-03-14T16:36:33.416476\"}","payloadType":"json","repeat":"","crontab":"","once":false,"x":110,"y":620,"wires":[["ba3e2c9.e64ccd"]]},{"id":"ba3e2c9.e64ccd","type":"function","z":"c05a9503.0c154","name":"Temp only","func":"msg.payload = msg.payload.Temperature;\nreturn msg;","outputs":1,"noerr":0,"x":290,"y":540,"wires":[["f317c453.45bc5"]]},{"id":"f317c453.45bc5","type":"switch","z":"c05a9503.0c154","name":"","property":"payload","propertyType":"msg","rules":[{"t":"gte","v":"21","vt":"num"},{"t":"lt","v":"21","vt":"str"},{"t":"gt","v":"22","vt":"num"},{"t":"lte","v":"22","vt":"str"}],"checkall":"true","outputs":4,"x":150,"y":740,"wires":[["172e4e26.c22e92"],["fddaae27.5e05b"],["e8890ada.59b838"],["aa5697a4.2ba36"]]},{"id":"fddaae27.5e05b","type":"trigger","z":"c05a9503.0c154","op1":"","op2":"","op1type":"nul","op2type":"pay","duration":"5","extend":false,"units":"s","reset":"stop low","name":"Activate Low","x":510,"y":720,"wires":[["cd9e7b62.03843"]]},{"id":"e8890ada.59b838","type":"trigger","z":"c05a9503.0c154","op1":"","op2":"","op1type":"nul","op2type":"pay","duration":"5","extend":false,"units":"s","reset":"stop high","name":"Activate High","x":510,"y":780,"wires":[["d3d50d57.1542d8"]]},{"id":"172e4e26.c22e92","type":"change","z":"c05a9503.0c154","name":"Stop Low","rules":[{"t":"set","p":"payload","pt":"msg","to":"stop low","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":320,"y":700,"wires":[["fddaae27.5e05b"]]},{"id":"d3d50d57.1542d8","type":"change","z":"c05a9503.0c154","name":"Set to 0 (OFF)","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"DeviceID\":\"0b625d5d-ac87-4e9b-80b9-6c4d1aa61f9e\",\"Actions\":[{\"ObisCode\":\"63000C0001FF\",\"Value\":0}]}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":700,"y":780,"wires":[["688395ea.7cccdc"]]},{"id":"cd9e7b62.03843","type":"change","z":"c05a9503.0c154","name":"Set to 1 (ON)   ","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"DeviceID\":\"0b625d5d-ac87-4e9b-80b9-6c4d1aa61f9e\",\"Actions\":[{\"ObisCode\":\"63000C0001FF\",\"Value\":1}]}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":690,"y":720,"wires":[["de514b92.b47b78"]]},{"id":"eee968cc.9687","type":"smooth","z":"c05a9503.0c154","name":"","property":"payload","action":"mean","count":"10","round":"1","mult":"single","x":380,"y":620,"wires":[[]]},{"id":"aa5697a4.2ba36","type":"change","z":"c05a9503.0c154","name":"Stop High","rules":[{"t":"set","p":"payload","pt":"msg","to":"stop high","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":320,"y":800,"wires":[["e8890ada.59b838"]]},{"id":"63571ec5.0e99c8","type":"comment","z":"c05a9503.0c154","name":"left out for testing ","info":"","x":540,"y":620,"wires":[]}]

AIOT MAKER

unread,
Mar 14, 2018, 8:38:22 PM3/14/18
to Node-RED
Hello,

Considering your very first flow  I understand that the temperature measurement should be updated every 10 seconds, thanks to the inject node and http request node that reads the temperature.. 

If you add the proposed flow as below then it should works all right  regardless of the status of the wall plug switch, right ?




Ventsislav Gyondrov

unread,
Mar 15, 2018, 6:10:33 AM3/15/18
to Node-RED
Hi AIOT MAKER

You are absolutely right the flow is working exactly as expected it was my mistake. Sorry
Reply all
Reply to author
Forward
0 new messages