Thermostat with PID controller

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.

13 Likes

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?

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.

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

Iā€™would be happy to hear from your expirence

1 Like

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!

Just build something custom with lovelace and custom components

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

1 Like

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

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.

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.

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)?

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.

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

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)

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

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.

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.

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.

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ā€¦

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.

2 Likes