expire_after is HA configuration option. Currently by default MQTTPublish/MQTTHomeAssistantConfig does not set it. More information, https://www.home-assistant.io/integrations/sensor.mqtt/#expire_after
On Wednesday, 15 July 2026 at 08:20:12 UTC-4 Rob M wrote: > I was using matthewall's MQTT with my old weewx instance and I think > you're right I didn't have these problems, it just worked. It just begs > the question, why would the retain flag matter at all like you say. The > one thing you mentioned that I have never set with either MQTT publish > extensions is the expire_after. Could it be without retain that the data > is expiring immediately for some reason? > > On Sun, Jul 12, 2026 at 6:19 PM Greg Troxel <[email protected]> wrote: > >> "[email protected]" <[email protected]> writes: >> >> > I realized that without the retain, the HA plugin had nothing to work >> with >> > because the timing on my weather data is so different depending on what >> it >> > is, my wind data is every 5 seconds and my archive period is 3 minutes >> so >> > all my other raw data from my weather station posts every 3 minutes as >> > well. >> >> This doesn't make sense to me. Without retain, when weewx is connected >> to the broker, and HA is connected (the normal case, should be true >> almost always), then MQTT posts from weewx arrive at HA. If you are >> sending data every three minutes (because your archive interval is 3 >> minutes and you are sending archive data), then within 3 minutes of >> starting HA the data should populate, and you should probably pick 180s >> or 390s for expire_after. If this doesn't work without retain, then >> something is very broken and we should figure it out, not tell people to >> set something which is semantically troubled. >> >> I have retain=False using [email protected]:matthewwall/weewx-mqtt.git and >> my weather data in HA is stable, but goes to unavailable when my weewx >> computer stops transmitting. >> >> > Because everything is so out of sync I have to use retain or it will >> > never get anything to work with. >> >> This doesn't make sense to me either. There is no need for >> synchronization of various entities, as long as they are all valid. >> >> > Also as far as the LWT, I just AI'd it and it suggested that HA enjoys >> > having that set. >> >> That is incorrect; HA is not a person and does not enjoy anything! The >> point of the LWT, as I said earlier, is to post offline to the online >> topic on client disconnect, so that the posting of online at connection >> is withdrawn and the availability topic has the right semantics. You >> should look at the json config that MQTTPublish uses, or your own >> config, to see if that is correct -- and see the page I referenced >> previously. >> >> > I did set up MQTTPublish and the HA plugin with json because I had no >> > reason to break out the topic individually. >> >> What "HA plugin"? HA has "integrations", and something (formerly called >> "add-ons") called "apps". The MQTT integration is built in. >> >> > My raw data from my weather station on the other had posts >> > individually. >> >> What do you mean "raw", and how is that happening -- if you aren't using >> MQTTPublish? >> >> >> Sending json is nice because there's one MQTT message posted. If you >> are sending archive data every 3 minutes (I do, but every 5), then >> there's one message, with everything, logically consistent in time. >> >> With loop, whether things are in json or not, they aren't quite >> consistent because data arrives to weewx at different times. As long as >> the delays are small (sub 30s?), it's not a big deal. >> >> If you have wind every 5s, then putting everything in json might lead to >> a full json every 5s, retransmitting previous values for other things, >> and ingesting them into HA again. It would be better in my view to >> split out wind to not be in json (or to be in a separate higher-rate >> json) to avoid transmitting data that isn't really data. >> >> >> Overall it sounds like you have found a configuration by guessing at >> settings but that it isn't really grounded in a plan of how things >> should be. I encourage you to examine what is being sent on MQTT and to >> read the HA entity configuration, in yaml if you did it yourself, or to >> read the autoconfig json if you're doing it that way. >> > -- You received this message because you are subscribed to the Google Groups "weewx-user" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion visit https://groups.google.com/d/msgid/weewx-user/52e0bf7e-640c-4cc4-9d1c-9e3b08d1da43n%40googlegroups.com.
