ScratMan / HASmartThermostat

Smart Thermostat with PID controller for HomeAssistant
336 stars 48 forks source link

Only One Instance of the Thermostat works as Expected #133

Closed dstewartwhite closed 1 year ago

dstewartwhite commented 1 year ago

Smart Thermostat PID.pdf HA Config Text.txt home-assistant_2023-02-20T16-25-48.406Z.log

Describe the bug There are two configurations of the Thermostat in the configuration.yaml file. Only the first configuration thermostat works as expected. The second does not trigger any response to an actual temperature difference to the Target.

To Reproduce Create two configurations to control separate heaters at different temperatures

Expected behaviour That both configurations would control their associated heaters individually.

Screenshots image

Shows the heater being turn Off despite a temperature difference after being triggered on manually image

Desktop (please complete the following information):

Additional context If each configuration is entered into the configuration.yaml file separately they work as intended controlling the specified heater. If the second heater is triggered manually, irrespective of the temperature error the thermostat switches Off the heater.

ScratMan commented 1 year ago

Hi, which version are you using ?

dstewartwhite commented 1 year ago

Hi

Upgraded to your latest this morning 2023.2.1 prior to submitting the Issue #133.

Regards

Sent from Mailhttps://go.microsoft.com/fwlink/?LinkId=550986 for Windows

From: Adrien @.> Sent: 20 February 2023 18:48 To: @.> Cc: @.>; @.> Subject: Re: [ScratMan/HASmartThermostat] Only One Instance of the Thermostat works as Expected (Issue #133)

Hi, which version are you using ?

— Reply to this email directly, view it on GitHubhttps://github.com/ScratMan/HASmartThermostat/issues/133#issuecomment-1437425018, or unsubscribehttps://github.com/notifications/unsubscribe-auth/A3I7ONKCYJVSG7UMKSJHYHLWYO37LANCNFSM6AAAAAAVCEQF3M. You are receiving this because you authored the thread.Message ID: @.***>

ScratMan commented 1 year ago

Your log only mentions some OFF commands, the control output is always 0.00 because temperature is above the set point on both thermostats, so there is no activation needed, and the switches are never toggled ON.

Your capture seems to be more recent than the log, and the switch off is requested by home_assistant.turn_off, so it seems to be related to the smart thermostat, bit the switch on is requested by the service switch.turn_on ; so it looks like something (an automation or a script) is turning on the switch and the keep_alive of the smart thermostat then forces the switch to OFF as there is no need for heating.

dstewartwhite commented 1 year ago

Attached a new log file to ensure all actions are in sequence home-assistant_2023-02-21T09-58-11.708Z.log

This screen dump shows that the Seed thermostat (2nd in Config file) target temp is above the target sensor temp, so the thermostat should I believe be activated and indicate "Heat" not "Idle" image

Log book of the seed heater switch. Not turned on after adding second thermostat to config and restart. image

I disabled the automation scripts that are used until I can get the second thermostat to work.

The final screen dump shows the history of the seed thermostat from the last HA restart image

ScratMan commented 1 year ago

That's strange as the log mentions output of 0.00 with error=2.10 and p=0.00 while the kp is 40.

Could you please set debug: true for both thermostats in the config and post the full state of each thermostat by going to Development tools \ States and selecting them in the list. The "entity state" Yaml should look like this :

hvac_modes:
  - heat
  - 'off'
min_temp: 7
max_temp: 30
preset_modes:
  - none
  - away
  - eco
  - boost
  - comfort
current_temperature: 21.1
temperature: 21
hvac_action: idle
preset_mode: none
away_temp: 14
eco_temp: 19
boost_temp: 25
comfort_temp: 21
home_temp: null
sleep_temp: null
activity_temp: null
control_output: 0
kp: 64
ki: 0.007
kd: 125000
ke: 0.6
pid_mode: auto
pid_i: 2.5
friendly_name: Thermostat salle de bain
supported_features: 17
dstewartwhite commented 1 year ago

As requested, both thermostat's debug set to "true" and HA restarted

Entity States

hvac_modes:

hvac_modes:

ScratMan commented 1 year ago

Here is the root cause of your issue:

kp: 0
ki: 0
kd: 0
ke: 0

The gains are restored from previous known state at boot, and the values in the YAML are ignored except is the HA database is deleted or crashes. The first release of 2023 introduced a bug that prevented correct restoration of the gains and it forced them to 0. That's why the output of the PID is always 0.

You need to use the smart_thermostat.set_pid_gains service to set back the gains to the expected values in developer tools https://my.home-assistant.io/redirect/developer_services/ . The code to call the service should look like this :

service: smart_thermostat.set_pid_gain
data:
  kp: 40
  ki: 0
  kd: 0
  ke: 0
target:
  entity_id: climate.smart_thermostat_seed_pid
dstewartwhite commented 1 year ago

Hi I have used the service to set the PID values and now it is working as expected.

I have a couple of further comments. The issue ONLY appears to effect the second configuration, in my case, as its gains values are being set to 0. The first configuration values are not effected. The issue was present in at least the last two releases of 2022, as I first started to get two thermostats running in November last year. Regards

ScratMan commented 1 year ago

There have been no release between 2022.2.1 in February '22 and 2023.1.0. In the 2023.1.0 I brought back the integration reload service, but the timers were not stopped when the thermostat was unloaded by Home Assistant. So if something reloaded the integration, it created a second set of timers for the same entity, and depending on the sync between the redundant timers, it could create some big troubles. It also introduced a bug in the gains value restoration, that has been fixed in 2023.1.1. The 2023.2.0 release fixed the timer issue, so when setting back the correct gains on latest release, everything should be fine again.