ScratMan / HASmartThermostat

Smart Thermostat with PID controller for HomeAssistant
338 stars 49 forks source link

Can I somehow get Control Output with both positive and negative values? #42

Closed MarkoPaasila closed 2 years ago

MarkoPaasila commented 2 years ago

Is your feature request related to a problem? Please describe. I want to try using PID for controlling the target temperature of my heat pump. Currently it only gives either positive or negative output, and cuts out at zero.

Describe the solution you'd like I would like to get a Control Output (using a template sensor), that works both ways.

Describe alternatives you've considered I currently use a Python script with quasi-proportional control. I need it to warm up the surrounding air in excess, then switch to fan_only mode to spread it around the home. Otherwise it will just warm it's own surroundings to the target temperature, and everywhere else will be too cold. In the summer it's the opposite.

Additional context I think PID is the right solution to my problem - and an elegant/cool one.

ScratMan commented 2 years ago

Why both positive and negative value ? a modulation can't be negative, it's either 0%, 100% or anything in-between. You can't have -20%.

MarkoPaasila commented 2 years ago

Positive for heating, negative for cooling. I just realized that pid_p seems to be doing what I thought control output was; giving both positive and negative values. But pid_p doesn't include the I and D, so I need to combine them separately.

ScratMan commented 2 years ago

There is an AC mode already to cool down, but the thermostat can't do both at the same time, theoretically the AC is set to either heating or cooling modes.

Anyway, you may get the P, I and D components of the PID output in the thermostat's attributes using templates, and add them by yourself to get a negative value.

MarkoPaasila commented 2 years ago

Ok I'll do that. Thanks!