Why does the Generic Thermostat not keep it's state after a reboot or update?

I use the Generic Thermostat to control my pool heater. Whenever I reboot or do an update, the heater kicks on and I have to stop it and reset the temperature. I know this has been mentioned before in other threads, but I haven’t seen it listed recently or in the “WTH” section. Apologies if this has already been discussed or dismissed.

Thanks!

I think this is more or less associated with your setup of the generic thermostat or the target_sensor’s value on startup being outside the range.

Thank you for the response! I will do some more reading/searching to see if I can find some more details to resolve.

Thanks.

You could just post the configuration of the thermostat and we can have a look at it

Ok - thank you!

- platform: generic_thermostat
  name: Pool Heater
  heater: switch.pool_heater_shelly
  target_sensor: sensor.pool_water_temperature_measurement
  min_temp: 70
  max_temp: 104
  ac_mode: false
  target_temp: 86
  cold_tolerance: 1.5
  hot_tolerance: 0
  initial_hvac_mode: "heat"
  away_temp: 75

What does the temperature sensor say as you reboot?
If it’s unavailable, for how long?

Not really sure how to check the temp sensor as I reboot. If I look in the logs I do see “Timeout fetching Pool Heater Shelly data”. Thanks.

Is that the state of sensor.pool_water_temperature_measurement?
If so then that is the case I believe. It returns as 0 when converted to a number.
I honestly think this is a bug in the generic thermostat then, it should discard non numeric characters.

There are ways around it in the mean time, but just confirm this is the state from the logs or history of the entity

I’m fairly certain it’s because he’s using initial hvae_mode as heating instead of ‘off’.

I have to defer to the documentation because I haven’t read the code yet. That field leads me to believe that’s the startup mode.

Pardon the image, but mine are also on heat:

I believe, if you set it to off then you need to turn on the climate entity before it starts regulating the heat.

I believe the temperature is between his thresholds but because it returns 0 at startup, it kicks in then remains on until it reaches the upper threshold.

Yeah, that’s what I was thinking originally, but I wasn’t sure when I saw that initial field. I don’t use the integration, I was just speculating.

When I look in history I only see line items for when I turned the heater off, not for when it started by itself after a restart of HA.

What’s interesting is that the thermostat is set to 86 degrees, which is a setting I have in my automations (both of which are disabled right now).

So on restart of HA, the generic thermostat is set to 86 degrees and kicks on, even when the prior state was off, temp was set to 70 and the automations were disabled.

Thanks by the way for the thoughts and suggestions, truly appreciate it.

We need to see the sensor.pool_water_temperature_measurement in developer tools like this:

Does it have a dip down to 0?
Why do you have automations?

What temp was on 86? Target temp?
What is set to 70?


It doesn’t appear to dip down to 0.
The automations are to turn the heater on and off on certain days in the summer. We don’t heat the pool non-stop. During peak summer months, we would heat the pool later in the day to ensure it was at our desired temp for after school/work. On Weekends we’d heat it earlier due to no school/work. If the temp was high enough it wouldn’t heat, if not it would heat to the set temperature. Then an automation would turn off the heater at sunset since we didn’t swim much after dark.
The automations will be disabled for winter and I will cut the power to the devices via the circuit breaker box (as part of the pool closing for the season).

Looking at that graph it’s quite obvious it heats the pool.
Your temperature is below the lower threshold.
So probably you have manually (or by automation) switched off the generic thermostat, when you restart the initial HVAC mode is heat, and the heating begins.

Not sure what (or if possible) will happen if you leave that line out.
Will it remember previous state? Doubt it…

But you could use the events homeassistant_stop and homeassistant_started events to set a boolean of the state it was at stop, then use start to set the climate entity to what it was prior to restart by looking at the boolean.

Thanks for the suggestion of homeassistant_stop/_started…I’ll look further into how those work and how I could leverage that for my setup.

Again, thanks for all the feedback.

Hi,

I ended up installing the automation suggested by akasma74 (on 1st April) in this tread for my units, so that they are restored to the same value after a restart.

So basically the step is to record/store every change to the thermostat and then use an automation to restore them after the restart

It is a bit coding, but it has sofar worked well.

Hi,
How can i change the target temperature on the generic HA thermostat?
My AC temperature sensor is fk up.
Thank you!

Service call: climate.set_temperature

Right, but i want to change the target temperature to a aqara sensor, not a number. Do you know hot is done? Thanks!