I have Teslamate running in docker on a Mac mini, and Home Assistant running on a Pi 4. Recently, I noticed that whenever anyone was driving the car, my automations would show a huge lag between trigger and action. Most of them are in Node Red, and I noticed for example that after one would trigger, the call service node to say, turn on a light, would stay yellow for a long time, before finally turning green and the light would turn on. Normally, it would be instantaneous.
I tried to troubleshoot a bit and installed the systemmonitor integration. I could clearly see every time I would drive, the processor on the Pi would shoot up to well above 50% and stay there for the duration of the drive, with occasional peaks going up even higher. Normally, I run at about 10%. If I wasn’t the one driving and I was at home, I would be able to verify that all the automations would start to run slowly.
Some more investigation showed that neither Mosquitto nor Node Red appeared to be the ones using the processor, so it must have been something within Home Assistant. I set up a simple counter to see how often the Teslamate entities were being updated during a drive, and I was surprised to see that they were updating thousands of times during a 20 minute errand run. Which makes sense if you think about it I guess, given that things like speed, latitude, power, etc is constantly changing while you’re driving.
I have had this set up for over a year, and I never noticed it before. However, since I’m usually the one driving this car, I would not have noticed any slowdown at home. So I’m not sure if it’s always been there,
I fixed the problem by moving the entities that seem to change the most (e.g., odometer, speed, power, etc) out of the mqtt.yaml file and making an automation I Node Red which throttles the update of the home assistant entities to something more reasonable, one every minute or even slower for some of them. If others are seeing this problem, and are interested, I’d be happy to post more details about the process.