this post was submitted on 14 Nov 2023
19 points (100.0% liked)

homeassistant

12146 readers
53 users here now

Home Assistant is open source home automation that puts local control and privacy first. Powered by a worldwide community of tinkerers and DIY enthusiasts. Perfect to run on a Raspberry Pi or a local server. Available for free at home-assistant.io

founded 2 years ago
MODERATORS
 

I'm pretty new to HA. I've set it up and I keep editing the confirmation and everytime I restart to apply the changes, all the switches, sensors and even the thermostat lose their values. The most annoying is the thermostat (classic thermostat entity) because I have to turn it on selecting heat/cool and set the temperature. Is there a way to keep all these values across restarts?

Edit: I'm using HA OS on Proxmox. All the sensors and switches slowly goes back to "normal" as soon as they publish their state, apart from some entities that have values provided by HA itself and not by the devices (like the thermostat).

all 33 comments
sorted by: hot top controversial new old
[–] [email protected] 9 points 1 year ago (1 children)

That's strange, it usually does keep that, because the values are coming from the devices themselves. Like a switch is either on or off as soon as HA reconnects, it requests the state of the switch. Same for thermostats, at least in my case, because mine are connected via the router via DECT. It may helps to provide some more details on your installation (Docker, HASS OS, ...) and devices

[–] [email protected] 1 points 1 year ago (1 children)

I've edited the post with some other information. About your configuration, how does HA ask for the state? This mean that your HA loses all the values too, but it repopulates them automatically. What about the entities that provides values FROM HA itself? For example the setpoint of the thermostat?

[–] [email protected] 1 points 1 year ago (1 children)

During restart all entities are in state unavailable. When the integrations are loaded all the entities with their current states become available again, but that's something of seconds. The internal entities, like Helpers, are immediately available - that's the closest to "value from HA itself" I have in my setup

[–] [email protected] 1 points 1 year ago

The internal entities, like Helpers, are immediately available

This is my problem:in my main HA instancd the internal entities are in state "unknown" when I reload the configuration. In another instance of HA everything works fine and the thermostat goes back to their previous state when I reload the configuration, in the "main" instance they don't :(

[–] [email protected] 7 points 1 year ago* (last edited 1 year ago)

Are you using Docker? Forgive me if you know and understand docker - I'm just checking to make sure, but if you're using Docker are you sure you set up your volumes correctly? Docker is stateless, so on any restart it would lose all of your info and be a clean install if you did not set up your volumes correctly

[–] spaghettiwestern 4 points 1 year ago* (last edited 1 year ago) (1 children)

Something's wrong with your configuration. What hardware, OS and HA config are you running?

My HA install does not lose anything when restarted. All my wifi, Z-wave & Zigbee devices, various entities and thermostat come back in the same state as prior to restart. I've run HA Supervised on two HW platforms and 3 distros and they've all functioned this way.

[–] [email protected] 1 points 1 year ago (1 children)

I'm using HA OS on Proxmox. About the configuration, what do you need to know? Do you wanna see it all? All the sensors and switches slowly goes back to "normal" as soon as they publish their state.

[–] spaghettiwestern 1 points 1 year ago (1 children)

HA OS on its own doesn't behave that way, so that leaves Proxmox or perhaps your specific hardware. Can't help you though. Haven't tried HA in any kind of virtual environment.

[–] [email protected] 1 points 1 year ago (1 children)

Indon't think that the problem can come from Proxmox/HW since it happens everytime I restart the services, not the VM. So strange...

[–] spaghettiwestern 1 points 1 year ago* (last edited 1 year ago) (1 children)

Perhaps so, but I've run HA on a Raspberry Pi under Raspberry OS, HA OS on that Pi, and HA Supervisor on a PC using Debian and am currently running it on a PC under Linux Mint. All of these worked with little or no delay between HA start and device status updates.

[–] [email protected] 1 points 1 year ago

Since the updates comes from the devices and ate not requested from HA, some exposes their statuses in less than a minute, some (like temperature sensors that are battery powered) sends their statuses very less frequently (if the temperature doesn't change, they communicate every 30/40 minutes.

[–] [email protected] 2 points 1 year ago* (last edited 1 year ago) (1 children)

Restoring the states depends on the recorder. What are your settings regarding the recorder?

Edit: reference https://www.home-assistant.io/integrations/recorder/

[–] [email protected] 1 points 1 year ago (1 children)

Ah, interesting!!! I've tried enabling it just by adding recorder: in it the configuration file that, if I didn't get it wrong, should record everything without exclusion, but...it doesn't sensors/switches/thermostat setpoint and state are lost at config reload. Am I doing something wrong?

[–] [email protected] 3 points 1 year ago (1 children)

recorder is enabled by default. however, when you are using docker it might be possible that the default file data base (it's folder) is not mapped to a persistent location outside the container (resp. in the host file system).

however, I really do not know much about all this docker related stuff. my recorder suggestion was just a shot into the blue. if I would be facing this problem I might just try to set up a relational data base like MySQL or PostgreSQL as a target for the recorder.

[–] [email protected] 1 points 1 year ago (1 children)

The recorder was indeed already enabled, I've noticed from the home-assistant_v2.db file. Nevertheless I'm still losing everything when I reload the config. I'm not using docker, but HA OS. Any other...shot in the blue? 😁

[–] [email protected] 1 points 1 year ago (1 children)

is the history of the values available after restart? like the graphs shown when you click a sensor entity?

[–] [email protected] 1 points 1 year ago

Yes, the history of there, with some blanks around the time I've done some config reload

[–] [email protected] 1 points 1 year ago* (last edited 1 year ago) (1 children)

When you restart HA, keep an eye on the Summary tab for the Proxmox guest. If you're seeing CPU or memory spikes going into the red, you might need to assign more resources to the guest. Also take a look at swap and boot disk utilization - do they seem particularly high?

Also, over what period of time to the "go back to normal"? A few minutes, half an hour, more?

[–] [email protected] 1 points 1 year ago (1 children)

Nothing like that, the resources are more than enough, no peaks. It "goes back to normal" when all the sensors/switches have sent their status and when I manually turn the heater back on and set a new setpoint for the thermostat

[–] [email protected] 1 points 1 year ago (1 children)

How network-savy are you? I'm thinking you could run tcpdump on your HA server and capture network packets while restarting HA, then inspect in Wireshark.

Most devices don't actually "send" their status to HA directly. It'll (usually) be HA querying their status (the exception being devices that publish via intermediate services, like MQTT). Inspecting the network packets might reveal more about what's going on.

[–] [email protected] 1 points 1 year ago (1 children)

All the devices (sensors and switches )sends their status via MQTT; I've manually configured them all via yaml. The problem is in HA itself since as soon as I reload the config, the thermostat (which is a HA entity by itself), loses the setpoint and the status (heater/cool/off).

[–] [email protected] 1 points 1 year ago (1 children)

@peregus @DeltaTangoLima I am not an expert by any means, but I think there is a state "recall" somewhere that tells mqtt and or ha to keep last state

[–] [email protected] 1 points 1 year ago (1 children)

For MQTT that's the retain flag, but for HA I don't know what that is and I really need it!!!

[–] [email protected] 1 points 1 year ago (1 children)

The retained flag simply tells the MQTT broker to keep the last message published for that topic, so it's always available (rather than timing out and emptying the topic).

Like I said, you should probably do a packet capture to see what's happening when HA queries states (either from devices or MQTT - it doesn't matter).

[–] [email protected] 1 points 1 year ago (1 children)

HA doesn't query any state. The thermostat is within HA, it doesn't have to query anything from anything, that's what I'm investigating. The setpoint is set in HA and HA retains that number.

[–] [email protected] 0 points 1 year ago (1 children)

That doesn't make sense. HA doesn't "own" the setpoint - the physical thermostat does. All HA is doing is telling the thermostat what setpoint to use, as if you were standing in front of the thermostat yourself.

What thermostat are you using?

[–] [email protected] 1 points 1 year ago (1 children)

The thermostat is an entity in HA, there is no phisical thermostat! It's a generic thermostat!

[–] [email protected] 0 points 1 year ago (1 children)

Ah, so your real issue is just the thermostat? Your OP made it sound like you were asking about all switches and sensors.

Is it just the setpoint that you're losing and not getting back after restart? I'm assuming it's getting the current temp back from the sensor just fine?

[–] [email protected] 1 points 1 year ago (1 children)

No, my problem is not just the thermostat! All the sensors and switches loses their state, but while they get them back in a while kapart from the battery powered sensors), the thermostat has to be set back manually.

[–] [email protected] 0 points 1 year ago (1 children)

Jesus, you're not exactly making it easy here mate. Feeding info piecemeal, to someone who's spending time to try and help you, only frustrates both of us.

Re the sensors and switches, you said they're all sending states via MQTT. Are they setting the retained flag? If not, that's the problem. If so, run a packet capture to see what's happening when HA restarts - maybe it's not querying MQTT successfully straight away or something.

Re your thermostat, can you post your config? There's a few threads on the HA community forums that are complaining of similar issues, with various causes/solutions discussed.

[–] [email protected] 1 points 1 year ago (1 children)

I'm sorry if you think that I'm wasting your time. From my point of view, it's the other way around since all it's written in the OP! And you still saying to run a packet capture means you didn't get the point or you know HA less than me!

[–] [email protected] 0 points 1 year ago

means you didn’t get the point or you know HA less than me

Your OP says "everytime I restart to apply the changes, all the switches, sensors and even the thermostat lose their values". Later on, you've said that you configured all your switches and sensors to publish their states in MQTT. Hence why I'm saying you need to look at how and when HA is querying those states.

You've since clarified that the thermostat is a generic thermostat entity, where HA controls setpoint. Without having posted your config, I'm left to assume that HA turns your HVAC on/off based on a temp sensor state.

I've been running HA for many, many years, and am a network guy by trade. I'm only trying to help, but you're now assuming I'm either not getting the point or know less than you.

No worries, mate. Best of luck. 👍