Thermostat with PID controller

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

That’s great, thanks for clarifying!

I looked at Nest but was put off by the number of outages they’ve had over the last few years… Your new project sounds great!

Hi @fabian.n

I have updated to 0.84.3 and now I have this error

2018-12-18 09:42:51 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 "<frozen importlib._bootstrap>", line 994, in _gcd_import File "<frozen importlib._bootstrap>", line 971, in _find_and_load File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 665, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 678, in exec_module File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed File "/config/custom_components/climate/smart_thermostat.py", line 28, in <module> from homeassistant.helpers.restore_state import async_get_last_state ImportError: cannot import name 'async_get_last_state' 2018-12-18 09:42:51 ERROR (MainThread) [homeassistant.loader] Unable to find component climate.smart_thermostat 

Do you know if the last version breaks the component?

Thanks

I’ll test it, haven’t worked with this version in a while now. Are you sure everything is still where it belongs (file order). It look like it can’t find smart_thermostat anymore but it’s defined in your conf. The file probably got deleted or moved.
Can you open a issue on github?

No changes after updating and when I reverse to 0.83.3 everything started to work again.
Issue opened in GitHub

Hi. Any idea of when you can reinsert min_cycle_duration? Is there an old commit that I can use to understand how that should be implemented?

1 Like

Hi Laffez, I’m sry for all the waiting. I hope I can fix it this week. It’s complicated to integrate, so it works fine. You for example don’t want it to turn on for 30min when the PID out is just on 1%.

Hello,
I was able to add and test it. It should work as intended, also the pwm and min_duration is now really in minutes. Tell me if something doesn’t work, Thanks.

1 Like

How do I go about installing this in hassio? As far as I know I can only ssh into the core.

Would it be possible to do this in appdaemon?

I do not seen the issue in providing it as a component in trunk. It is already a custom component.
Not everybody use hassio or want to start another daemon (appdaemon) while has already has a performant core with many many interesting components

How did you manage to get it to work? :slight_smile:

I followed the instructions but depending on your version of hass you may change the name of the py file to init.py The bad point is I uninstalled it as it didn’t worked as I was expecting because of the behavior of my sensors not reporting at temperature changes but on fixed times (every 15 minutes)