Thermostat with PID controller

Maybe with Home Assistant statistics using the heater switch. But I have no clue about how to do it.

You could use the History Stats sensor for periods that fit within the purge history time of the recorder, but not for months and years.

If you create a sensor that cumulatively counts how long something was on, then Utility Meter can create the day/week/month/year stats:

You could combine the two to get what you want:
Use a history stats sensor to count on time for today using the start of today as the beginning of the period, and now for the end of the period. Then use a utility meter to create a total for forever/year/week/month.

Hi,

I would like to configure my home smart PID regulator before winter and since I have time now I can start to make some work :slight_smile: . I have an issue that is not so obvious to me.

In my home I have several rooms and each of them have separate valves and wall thermostat. It means that I can control each room separately with set-up temperature for example of wall thermostat or from central from HA.

House has only one source of heating system (gas boiler) that can control by ON & OFF.

Till now I had a problem to control properly rooms since it was one sensor that took control over boiler and other rooms like office or bedrooms have been to cold or to hot.

By this integrity I can make an virtual thermostat and can control each of the room that is very nice. As well virtual thermostat can control of several valves etc. including boiler as well. But my question is how can I ensure that when Virtual thermostat will take control of room (valve) will start boiler and will not off when other rooms will require boiler since it supply whole house?
And I’m not sure how to make it correct due to the goal is to keep boiler ON till each rooms will meet required temperature. After that to shutdown boiler. And as well each rooms if will need more heat from boiler have to ON boiler to be able to heat room.

Is there anyone who had such case as solve it somehow :slight_smile: ?

Hello, it all depends on how the system is supposed to operate. You may drive the valves opening directly with the virtual thermostat (with pwm: 0 ), and use an input boolean template to make a logical ā€œorā€ so that the boiler is switched on if at least one valve is opened.

Sounds nice :slight_smile:
Do you have an example or where can I find so I could read a code and understood how it works?

Hello everyone, I want to use this component with Oventrop actuators via a solid state relay. It is designed with a wax filler and heats up in 2 minutes to fully open the valve, will this thermostat be suitable and will I be able to configure the system?

The winter is coming and many like myself are struggling to setup this integration, I’ve found this very useful simulator that has quite been a life saver, check it out - PID Simulator download | SourceForge.net

There are two versions, I found the first one more easy to use.

1 Like

Hi, is it possible to modify the preset mode icons?
After the latest OS update, I lost the mode icons. Now, the only way I can fix this issue is by setting them manually. I’ve successfully done this with the AC integration (Daikin), but I’m not able to do it with the Smart Thermostat.

I modified the icons.json file like this, but it’s not working:

{
  "services": {
    "clear_integral":  "mdi:thermostat-cog",
    "set_pid_mode": "mdi:thermostat-cog",
    "set_pid_gain":  "mdi:thermostat-cog",
    "set_preset_temp": "mdi:thermostat"
  },
  "entity": {
    "climate": {
      "smart_thermostat": {
        "state_attributes": {
          "preset_mode": {
            "state": {
              "home": "mdi:home",
              "boost": "mdi:rocket-launch"
            }
          }
        }
      }
    }
  }
}

Are anyone here still running HASmartThermostat thermostats from ? Are these still working?

As of yesterday all of mine became unavailable and reports "This entity is no longer being provided by the smart_thermostat integration. If the entity is no longer in use, delete it in settings."

Everything just stopped working yesterday at 13.30 (No update, no restart):

The log shows the following:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config.py", line 1437, in _async_load_and_validate_platform_integration
    platform = await p_integration.integration.async_get_platform(domain)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/loader.py", line 1070, in async_get_platform
    platforms = await self.async_get_platforms((platform_name,))
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/loader.py", line 1145, in async_get_platforms
    import_future.result()
  File "/usr/src/homeassistant/homeassistant/loader.py", line 1133, in async_get_platforms
    platforms.update(self._load_platforms(platform_names))
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/loader.py", line 1060, in _load_platforms
    platform_name: self._load_platform(platform_name)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/loader.py", line 1232, in _load_platform
    cache[full_name] = self._import_platform(platform_name)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/loader.py", line 1264, in _import_platform
    return importlib.import_module(f"{self.pkg_path}.{platform_name}")
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/importlib/__init__.py", line 90, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 995, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "/config/custom_components/smart_thermostat/climate.py", line 38, in <module>
    from homeassistant.core import DOMAIN as HA_DOMAIN, CoreState, Event, EventStateChangedData, callback
ImportError: cannot import name 'EventStateChangedData' from 'homeassistant.core' (/usr/src/homeassistant/homeassistant/core.py)

Very odd!

/Tonkin

Go to settings, input, click add input helper and select binary (boolean) sensor template.
Set the template value to something like

{{ is_state("valve.example_valve_1", "open") or is_state("valve.example_valve_2", "open") }}

And make an automation to switch the boiler on or off based on the state of this Boolean.

I tried to add some custom presets with their own icons, but didn’t manage to make new icons appear.
But I still have all the icons on my dashboard, no icon missing in the presets.

What are the HA and integration versions?
I’m running latest releases for both, without issue.

I am running 2024.4
Saw another example of cannot import name 'EventStateChangedData' from 'homeassistant.core' that was solved by an upgrade. Might consider to upgrade!

It was a core update issue. With 2024.11.3 all the icons are back again

Good morning, I am finally using this integration for real, and I am trying to set the values.
My system is an underfloor water-based heating system, and it is very slow, with a lot of inertia. The house is newly built, and the thermal insulation is good.
I set the minimum ON time to 10 minutes because, in my opinion, with less than 10 minutes, the floor doesn’t even start to heat up.
I set the minimum OFF time to 3 minute so that it doesn’t stay off for too long (but I might have completely misunderstood the approach).
As for the PID values, I took them as a reference from a post because it seems like a system similar to mine.

This is my initial configuration, and the result.
Does this look good, or should I change something? maybe there some overshoot and it doesen’t react fast when is near the setpoint.

  target_temp_step: 0.1
  min_temp: 5
  max_temp: 28
  target_temp: 20
  cold_tolerance: 0.2
  hot_tolerance: 0.0
  keep_alive: 
    seconds: 60
  kp: 18.724
  ki: 0.015
  kd: 5802.45
  ke: 0.6
  pwm: 00:30:00
  min_cycle_duration: 00:10:00
  min_off_cycle_duration: 00:03:00

many thanks

The interesting area is during the night, where the temperature is really stable, just a bit below the target. Maybe add a bit of ke gain, maybe 0.7, and increase the kd to 7500 to reduce the overshoot seen at the beginning of the capture.

I’ll try and report back in a few days!

Hello,
I am new to ā€˜Thermostat with PID controller’. I have good knowledge about control techniques and PID, so this isn’t the problem.
I added the sample into my configuration.yaml and changed the entityIDs of the sensors and the switch to devices I use here and restarted HA.

Nothing happens for hours, actual temp is 20.3°C, setpoint is 24°C, just to get some action on my test switch.

I also wanted to add some user interface, so I tried the Climate Card and the Mushroom Climate Card. As I should enter the entityId in the cards configuration, the system couldn’t find one.

What did I miss?

Is there a step by step explaination how to start from scratch, adding the thermostat, connecting devices and connecting some UI. And maybe a sample to see its working somehow, switching some virtual switch or whatever.

Thanks a lot for helping.

Maybe there is also a way to get debug infos to see, whats wrong.

((Have to control two TRVs in one project and a heat pump and 10 AC splits in 10 rooms in another project))

With best regards

Gerhard

Hello, make sure you don’t use the autotune. I think I should really remove that useless feature, I never heard about someone successfully using it.
Please share your configuration yaml, you may have entities that are incompatible with the example configuration. That’s an example, there is no guaranty it’s working.

You should look at the states panel in the developer tools, click the button below:
Open your Home Assistant instance and show your state developer tools.

look for your climate.your_smart_thermostat_entity and when clicking on the name, it will show the full status in the panel above.

The control_output attribute is the output value of the PID and represent the power requirement computed by the thermostat, if it’s high and the heater remains OFF, there is an issue in the control path.
If you click on the little circled i next to the name of the thermostat in the list in the bottom, it will open the control panel of the thermostat, and by clicking on the little squared chart icon in the the top right corner of this panel, you will see the climate history, showing the set point, the measured temperature and the heating requests.

image

Hi all, I’ve been away for a long time. For heating in our own house, we also developed a PID thermostat. I chose to separate the different parts required. So I created:

The components can be installed with HACS and visually configured. We are using them now for multiple years. Have been improving here and there, and we are satisfied with it. Feel free to test!