Automatic Climate Setup

I discovered Home Assistant about a month ago and have been thoroughly enjoying playing around with it. I wrote a bunch of automations that I had saved individually and then about 2 weeks ago I discovered and decided to have a go at the Node-Red integration… Since then I have transferred all of my automations over to Node-Red… Anyways, I love the community and wanted to share the setup I made for automatically controlling my thermostats based off of the current weather in my area and presence.

This was the most time consuming automation I’ve attempted so far but I am very happy with the results.
Features:

  • Allows for 1 hour temporary temperature hold if someone manually sets it
  • Automatically set the system into heat or AC mode
  • Checks temperature settings every 20 minutes (only updates thermostat if needed)
  • Has setpoints for when the house is occupied or unoccupied
  • Sets the temperature at night for when I’m going to bed
  • Notifies my mobile device whenever a change is made (this is mainly for debugging/making sure something unwanted didn’t happen - I’ll remove it eventually)

Now, I am not the best programmer and am completely new to this whole scene so bear that in mind before you judge how this was designed/coded. I am of course open to suggestions and tips/hints however… At any rate, here is what I’ve got!


The code and this message was too much to post here but I’ve uploaded the json file here:
AutoClimate.json

Also, these are the variables being used/manipulated
flow variables
flow.current.setpointup
flow.current.setpointdown
flow.current.mode
flow.last.temp_down
flow.last.temp_up
flow.occupancy

msg variables for function and after function
msg.data.match
msg.data.target_up.current
msg.data.target_up.home
msg.data.target_up.away
msg.data.target_down.current
msg.data.target_down.home
msg.data.target_down.away
msg.data.mode
msg.data.desired_mode