Thermostat with PID controller


#1

Hello

I reprogrammed the generic_thermostat. Instead of just turning on or off if the temp. is low or high, it now use a PID controller.

The output of the PID controller is between 0 and 100. You can chose to either just use this value or generate a pwm signal for switches.

Now I need some help.
The controller works and it would be great if someone can help me and make a good userinterface for the new Platform.
You need to be able to change the p, i and d property and it would be good if you see the controll output.

I’m new to homeassisant and don’t have that much time right now. I’ll share more information if someone think he/she would like to do this.


'Generic Thermostat' component doesn't ever switch heater on or off
#2

I have been looking for a pid_termostat for a while! I unfortunately do not have the knowledge to reprogram the user interface on the fly ( But could look into it if I manage to get it working for myself ).

Do you mind share the code for the reprogrammed generic_termostat?


#3

Currently I’m having alot of tests. I’ll upload the code with a documentary, on how to use it as soon as I have some time left.


#4

here you go.
https://github.com/fabiannydegger/custom_components

I’would be happy to hear from your expirence


#5

Hi there,

I can’t help you to achieve home assistant integration, but am very very interested in your plugin.

If I can be any help in testing, please concact me.

Keep going your great work!


#6

Just build something custom with lovelace and custom components


#7

Just tried it looks great ! Any chance this get integrated in home assistant by default?


#8

This looks really cool. I can see quite a few applications where PID would be useful!


#9

Thanks for this. I mean to post a while ago. I’ve been using this for quite some time now for an extractor fan, it’s difficult to tune, but once you get the PIDs right it is awesome.


#10

Hi, i’m trying to implement a simple PID controller for my boiler with some template se nsor, input numbers and automations.
Your custom component could be a simple way, is possible to use with Hass.io?
Can someone tell me the right way to install it?
Thank you.


#11

Hi,

I really need this for my floor heating. My only concern here is how does it control the output PWM? What is the minimum “on” time in the PWM, which I believe has to be 15 minutes for water-heating like the one I have? For water-borne floor heating, the normal “autotune” is often 14 days(!) due to cross correlation between different rooms/loops. But it seems like this scheme will tune each floor independently (to see how it best moves between different settings without overshoot)?


#12

Dears.

I have been struggling for days to get this component working, but I always get an error booting home-assistant and the smart_thermostat class is never created.

018-12-12 17:21:23 ERROR (MainThread) [homeassistant.loader] Error loading custom_components.climate.smart_thermostat. Make sure all dependencies are installed
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/loader.py", line 92, in get_component
    module = importlib.import_module(path)
  File "/usr/local/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "", line 994, in _gcd_import
  File "", line 971, in _find_and_load
  File "", line 955, in _find_and_load_unlocked
  File "", line 665, in _load_unlocked
  File "", line 678, in exec_module
  File "", line 219, in _call_with_frames_removed
  File "/config/custom_components/climate/smart_thermostat.py", line 9, in 
    import pid_controller
ModuleNotFoundError: No module named 'pid_controller'
2018-12-12 17:21:23 ERROR (MainThread) [homeassistant.loader] Unable to find component climate.smart_thermostat

I’m using hassio on docker under ubuntu linux.

Thanks for your help.


#13

Hi.

At the end I figure it out hot to deploy both components.
But I have some question:

@fabian.n @gsemet how does it works the autotune? Do I need to wait for how many time? what is the behaviour of the heating system while autotuning? is it normal the tempetaure decreases forever and when I turn off then on the heating system then warms forever? Do I need to set Kp, Ki, Kd before autotuning or after or both? When autotuning will be done, then should I comment the autotune line and modify the K’s values? Can I autotune more than one heating system at the same time? How I figure it out which K’s values belongs to which heating system?

Thanks a lot for your help.

It seems this can be a really big help to keep warm my appartment saving money and energy waste.

Sergi


#14

The auto-tune look how long it takes to heat the system up to the set-point and how fast it cools down. It then does this a few time to get an average image of the behavior. After it’s done (can take a day or 30 min depends on the system) you’ll have an message in the log. Just enter the values you get from there as if you would not use auto-tune and restart.
You have to create one entry for ever heating system, else you would control all system as one. If you do that u can auto-tune as many system as you can with your server. (This program can take a lot of ram, if your interval is small.)

How I figure it out which K’s values belongs to which heating system?

What do you mean? Please consider reading the help on github, for a deeper understanding of pid controllers and heatingsystems.

I’ve studied this for 2 years and still don’t really understand everything. I can just recommend not using the auto-tune for now, as it’s not really well integrated in the program. Get yourself a general idea how the p, i and d works and what the individually do. Just enter some ziglers values and look how it perform, then adjust it.

I working on a opensource project to make heating system with industrial standards available for everyone and easy to use. (image a nest, but it’s just software). You can wait for that or even help me. Sadly I have a ton of work right now, so I can’t tell when I’ll finish an alpha.

You can write down your experience of using a pid controller for the first time. That could help me so I get an idea of how people look at this. (not how it was to install it and get it running, just configuration and performance)


#15

I mean if I has three heating systems and I autotune all three at the same time everyone with their own entry, in the logs it will populate which entity the K values are from?

Ok. Fair enough.

I have readen some materials but I’m an absolute beginner about it. It will good to learn a new more thing (for me).

I’ll do, including the installation as it has its own challenge.

Thanks


#16

PWM output is controlled by a time value you set and then it turn it on and off proportional to the output value.
80% on 30min means the valve is 24min open and 6min closed.
As already mentioned the auto-tune is more experimental, it won’t really work well because it’s made for brewing and not for a floor heating process, wich is much more difficult to realize, due to windows, sunlight, sensor placement etc.

I removed * min_cycle_duration (Optional): I see that was a mistake. I’ll put it back in the new version.
For now you’ll have to do some programming yourself or set up an automation.


#17

I’m not sure but you’re right. You can try one and see if the entry is also mentioned in the logg, else that would be a problem. I think I missed that.


#18

Hi,

Thanks for your response. I am still programming temp sensors to use for target temp, so I expect to go PID early in the new year. To give you a sense of the time constants here, the floored water heating valve opens immediately when a relay opens. However, when it closes it spends about 2-3 minutes closing. In the current (offline, commercial) solution, I see in the manual that the minimum time open or closed is 15 min.

This would mean that you adjust the other state accordingly. 50% = 15 min off 15 min on, 25% = 15 min on, 45 min off etc.


#19

Sorry for my stupid question… But is this effectively an opensource ‘OpenTherm’ standard? Meaning the Boiler can modulate it’s heat demand?

Or is this more along the lines of the system knowing how long it takes your house to heat up by 1degree and extrapolate that out based on current inside/outside temperature so adjust schedules etc?

I’m a little lost…


#20

Clarification about the existing project:
It’s just a software thermostat that controles any heating or cooling system, with an pid controller.

Intention of my new project
Building a easy to use opensource software, that doesn’t require an account “somewhere over the rainbows…”
It’ll replace the physicall thermostat. Part of the Programm will be:
Controlling any room independant.
Overall control of the heatingsystem (Boiler, Heat pump etc.)
Optimation of general setpoint values, consider the Outside Temp. and the house type.
Cost effectiv heating with night tarif. (most used on Boiler)
Day plan, summer winter scedule.
and whatever I find usefull.

The goal is to reduce the general use of energy.
Depiste, I don’t want to collect data, I might add a option that you can submit your type of house and generall settings that work to make a autotune easier on first time use.

I’ll also make a guide on how to install sensors, what sensor work well and how they are connected. If you want to control your heat pump or something simular you shoud anyway ask your seller on how to properly connect to it.
Note: most new installtion already use Software like “OpenTherm”, which means: that they only optimize the heating process of the in system water. Not the actuall heating of the house.
However you can add any other hardware form a company that supports OpenTherm (Nest) to controll the actuall house.
Why is this not good? I don’t like the way they are connected, the price, it works only if they support the same standart.