PID controller for heating

Hi,

I’ll buy RFXcom device soon to control my heating (electirical) and multiply low cost sensor.
I wonder if a PID function exist on Home Assistant like on domoticz to be smarter with heating system ?

1 Like

Do you have a analog control capability of your heater?

I don’t think I’ve ever seen a residential heating or cooling systems with analog capability. I have seen only can be on or off, with a thermostat causing them to cycle as the temperature goes up and down to keep it between the setpoint and deadband.

These kind of heaters are quite normal in Europe, most if not all natural gas heaters available on the market today can be controlled in an analog way.

From a control theory point of view, this is however irrelevant. A PID controller can control a binary actor. That makes it a non-linear system, but with careful tuning and proper damping it can be done.

This kind of generic_thermosat would be great with PID :-). I hope it will be released :slight_smile:

1 Like

Added this to my to-do list

2 Likes

Any progress on this? :blush:

Not yet, many things on my to do :confounded:

How could this be implemented?

I’ve made an ESP8266 device which I control a small electric heater with. Did set it up as a MQTT Switch which I control with a generic thermostat. The logic in the ESP help to get the temperature fluctuations down to just 0.5K, but I know a fine tuned PID could probably manage even better.

The ESP switches the mains with a triac module controlled by a homemade PWM with 10 seconds cycle time, the heater heats and cools slow enough that this cycle time is unnoticeable.

I do not know if there is some MQTT components which take for instance a 0 - 100 signal and actuates upon that signal. The MQTT light can take an analog signal as brightness input to manipulate its output. But it is odd to connect a light to a thermostat.

Perhaps we should have a analog switch where which we could attach to the next version of generic thermostat?

I was thinking the same thing. Modulating a heating water valve. It would be nice to have a PID loop built in the Hassbian software. I am just getting involved with HA and the Raspberry PI 3 B+.

I’m starting to get into this, as I’ve got a side project that’s made it relevant. One of my first thoughts was “how could I apply this concept in Home Assistant?”. Outside of AppDaemon, I think this may be possible via templates, as the formula is relatively simple. Here’s what we’ve got

PID Formula

The PID controller Python library out on GitHub that @robmarkcole already linked provides an easy enough basis for the formulas that we could possibly adapt to Jinja templates.

output = (proportional_gain * (set_point - feedback_value)) + (integral_gain * windup_guard) + (derivative_gain * ((error - last_error) / (current_time - last_time)))

This is very oversimplified, but we could probably do this as a YAML package of a bunch of input_number entities, and just have an automation run every x increment of time to reprocess everything.

However, this is really something that should either be done as a component, or kept in AppDaemon, simply because of the number of moving parts. :confused:

I definitely feel like this would be a valid contribution to the Home Assistant platform and provide some great enhanced control over simpler devices. :+1:

Or you could use a python_script

you can use this, if you want https://github.com/fabiannydegger/custom_components
I’m happy for feedback

4 Likes