All value disappear after config reload

Hi all!
I’m pretty new to HA. I’ve installed HA OS on a Proxmox server.
Everytime I restart HA or reload the configuration the state of all the entities are lost: all the lights goes back to the 2 lightnings icons until they (bTicino switches with custom MQTT) publish their state again, all the temperatures disappears until the Aqara sensors publish the state again (even these are custom MQTT, I don’t use any integration) as well (and the most annoying) the generic thermostats that lose the setpoint and the state (heat/cool/off).
Here is my configuration.yaml file:

# Loads default set of integrations. Do not remove.
default_config:

http:
  use_x_forwarded_for: true
  trusted_proxies:
  - 127.0.0.1
  - 192.168.31.5
  ip_ban_enabled: true
  login_attempts_threshold: 5

# Load frontend themes from the themes folder
frontend:
  themes: !include_dir_merge_named themes

automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
group: !include groups.yaml


mqtt:
    light: !include_dir_merge_list lights/  #!include lights.yaml
    cover: !include cover.yaml
    switch: !include switch.yaml
    button: !include buttons.yaml
    sensor: !include sensor.yaml
    climate: !include climate.yaml
    binary_sensor: !include binary_sensors.yaml

climate.yaml:

- name: "Piano terra"
  unique_id: "MQTT_thermostat_PT"
  modes:
    - "off"
    - "heat"
    - "cool"
  mode_command_topic: "VM_casa/thermostat/PT/mode/set"
  mode_state_topic: "VM_casa/thermostat/PT/mode/state"
  temperature_command_topic: "VM_casa/thermostat/PT/temperature/set"
  temperature_state_topic: "VM_casa/thermostat/PT/temperature/state"
  current_temperature_topic: "VM_casa/PT/livingroom/temperature"
  min_temp: 17
  max_temp: 28
  temp_step: 0.1
  precision: 0.1

lights.yaml:

  - name: "Ingresso"
    unique_id: 'luce_ingresso'
    state_topic: "zigbee2mqtt/bTicino_switch_P0_ingresso"
    command_topic: "zigbee2mqtt/bTicino_switch_P0_ingresso/set"
    state_value_template: "{{ value_json.state }}"
    qos: 0
    payload_on: "ON"
    payload_off: "OFF"
    optimistic: false
    retain: false

I’ve tried using “retail:true”, but it didn’t do anything.
These are just singles entities of a lot, I didn’t want to write them all since they are all the same.
Thanks!

The devices that send the messages need have the retained flag set.

That will help HA to retrieve the state of those, right, but HA should retain the states itself. I have another installation where all the states are kept across config reload.
Moreover the thermostat status is managed and stored only by HA.

That’s not how mqtt works.

If the device sends retained messages they will be sent to home assistant from the broker as soon as it subscribes to the topics after a restart.

What I meant is that HA should keep the values over config reload regardless MQTT
Actually, it does, I’ve tried on another instance and it does keeps every sensor/switch/thermostat state even when I reload the config, even without the retain flag on the MQTT messages that the devices send.

Edit: sorry, I’ve done the test to quickly and I’ve turned off the wrong MQTT instance leading me to believe what I’ve written up here.

Then you have a magical installation as no others work like that.

Sorry about that, you’re right, I was working on 2 different HA instances and I’ve turned off the wrong MQTT broker while restarting the other HA that kept the lights value because of the retain messages.
But, but what about the entities that are created in HA itself that don’t even have MQTT?
For example I’ve just created a slider:

input_number:
  slider1:
    name: Slider
    initial: 30
    min: -20
    max: 35
    step: 1

If I change the value and reload the configuration the value is kept there in the HA test instance, but not in the production instance.
What could have I done wrong?

Yes that should be restored.

However you have specified an initial value (30) so it will be restored to that rather than the last value before the restart/reload.

Negative. I’ve just tried it 4 times. I’ve slide it at -3, reload the configuration and it’s still at -3.

Restart or reload?

Maybe it only occurs on restart?

Reload.

Correct. If I restart it it goes back to default value.
So the problem is in my production HA that loses the values even across reload…whyyyyy :sob:

I’ve just update to the latest version, but nothing.
Recorder is enabled.

Does anyone have any idea?
@tom_l nothing?