I have mosquitto broker running on the same server as home assistant. I have multiple (about 8) remote temperature sensors that report the temperature about every 15 seconds each via MQTT. I reallize they don’t need to be that frequent, but that’s how they work (Acurite $7 remote temperature sensor). If I connect a python script to the broker, I can see the messages flowing. I noticed in my HA panel that the last update from some of the sensors was several minutes old. When I looked in the logs, I see that HA is only reporting messages every once in awhile. Sometimes it’s quick (30 sec), sometimes it goes 10+ minutes between reading a message for a specific sensor.
I’d prefer not to turn on QOS for these messages since there are a lot of them and they’re real time updates. But I also can’t tolerate missing that many messages. And I have other sensors that only report every few minutes and those are being missed most of the time.
Any ideas why HA is not reading all the messages? It’s only running at 1% of my CPU…
Have you tried publishing via command line or the HA tool to see if the messages are going through? Also, in case you didn’t know, you can just monitor the messages via command line with mosquitto_sub. And why would you not want QOS? Obviously the messages aren’t making it to the broker so it just seems like going QOS 2 would make sense. It’s 2017. Unless you’re completely flooding your broker there’s no reason not for it to do a little more work.
I’ve got 3 Wemos, and 4 phones running mqtt right now and I’m not losing anything unless I tell it not to retain, and then that’s on me.
Like I said originally, I can see the messages flowing through the broker just fine. I think what’s happening is that HA is only logging when the sensor value changes. So when the detail view says “15 minutes ago”, that means the sensor value changed 15 minutes ago, not that the last message was seen 15 minutes ago. It would be nice if that showed the last time the sensor was received - I might look and see if that’s an easy fix to make.
you also have to consider this, if you’re using the retain flag and the message doesn’t change the message doesn’t change. So i think it uses the oldest message to display. So it could very well be that it hasn’t changed in 15 minutes because there’s nothing to change.
Your observation is correct. HA only reports a sensor update if the incoming value changes.
You can use set force_update: true on your MQTT sensor to force HA showing the latest update even if the value does not change.
Thanks - I don’t really want it to record all the reading if they’re not changing. But it would be nice if the detailed sensor view (clicking on the item) didn’t say “30 minutes ago” when it received an update 10 seconds ago. At least to me, that’s very confusing and makes it seem like there is a problem in the sensor. I may look into what it would take to report the last sensor time, not the last time it changed.
It’s kind of complicated. I have an acurite bridge from a weather station (which died last year) that reads the radio messages and tries to post then to an acurite web site. I have that connected using a USB network dongle to my Linux box and I use ebtables and ip tables to redirect its traffic to a python script which reads the messages and converts them to MQTT. It was a bit complicated to set up but it works great and I let’s me use $7 wireless temp sensors throughout the house.
Wow thanks for your reply, you’re talking about stuff I’ve never even heard of. Guess I’ll stick with the ESP8266 devices that I solder together, lol thanks
Ha - it’s simpler that it sounds. I knew it was uploading data so I found some a site talking about how to tap into that feed (basically a man in the middle attack), then I found a post about redirecting traffic and added those rules to my firewall, throw in a page of Python to parse the messages and it was working great. I don’t actually understand the firewall table rules at all, I just copied something someone else had done.
I don’t have an acurite bridge just old sensors wanting to be used. You piqued my interest to read about 433toMQTTto433 and RFLink and funny thing is I think I have all the parts to give it a go. One more project to add to the list lol. Maybe one of these could take out a layer in your project
Turn off the retain flag. That way it takes the next message, and the next message and so on. The problem with this is if you’re using a mqtt subscriber on your phone, or others, it won’t show a retained message so you’ll have to wait for the next one to be sent.