Yeah, something doesn't sound quite right. I haven't fully digested all of 
Greg's information. Here is what I have seen in my limited use.

I'm publishing loop topics to HA. I have 3 different loop packets. One is 
published very regularly ever 2 to 3 seconds (this contains the majority of 
my data). The other 2 publish every 15 to 20 seconds. So this is 3 
messages, each with different content.

When I was publishing json, I noticed that whatever sensors weren't in the 
MQTT message received -  would show unavailable. I thought I worked around 
this.... but this might still be happening. I also got around it by 
publishing each sensor individually. The other option would be to use 
different topics for the different data sets (loop packets). But again, I 
thought it should work. I'll experiment more.

The only place I use retain=true is MQTTPublish's LWT (and due to current 
implementaion its 'birth' message). Here is why I use it.
1. WeeWX goes down. MQTTPublish 'sends' the LWT message.
2. HA receives the LWT and marks the device/sensors unavailable.
3. HA goes down
4. HA comes up.
5. HA receives the retained message that WeeWX is down.

I find that setting up HA to publish LWT and birth messages and MQTTPublish 
to subscribe to them to be very useful. Here is the scenario this covers.
1. HA goes down and sends the LWT message.
2 MQTTPublish receives it (currently does nothing).
3. HA comes up, sends a birth message.
4. MQTTPublish receives it and republishes the device discovery 
configuration.
Note, having the device discovery message published with retain=true would 
also work. But, I like this better. MQTTPublish supports either. Your 
choice.
I believe this is necessary because HA doesn't persist the device discovery 
configuration across an outage.

Again, I am far from an HA expert. Just my observations from my setup.
I'm off to re-read Greg's information.
rich


On Sunday, 12 July 2026 at 18:19:52 UTC-4 Greg Troxel 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/8d65a949-e875-405c-b477-250765e6eb89n%40googlegroups.com.

Reply via email to