Closed jacekowski closed 7 months ago
The MQTT callback for:
message is the first thing the backend does after receiving the mqtt message. If there is a huge delay before this log message, this sounds more like an issue with the appdaemon (https://github.com/AppDaemon/appdaemon) than with this backend app.
Do you have configured core-mosquitto.local.hass.io
as address for mqtt in appdaemon?
I'm running mqtt broker in a separate VM (on same proxmox cluster and connected via 40G ethernet) so i'm using different address.
Latency is clearly not caused by MQTT broker or network (i can see MQTT messages delivered on time when i run tshark (message was delivered at 15 01:10:07.665517703 but backend log message only appears nearly 600ms later)), which means it's either appdaemon or this backend app.
How much latency are other people seeing?
AppDaemon is calling this function:
First thing that is done there is logging this calback message. I cannot run tshark to check the network packets, however there is also no long delay on my panels.
So, my further testing indicates that the issue is caused by appdeamon and how threading in python and appdaemon works.
This call https://github.com/AppDaemon/appdaemon/blob/dev/appdaemon/plugins/mqtt/mqttplugin.py#L311 schedules everything, but then there can be a significant delay between event actually being dealt with.
looking into appdaemons config options uvloop might improve this
https://appdaemon.readthedocs.io/en/latest/CONFIGURE.html#advanced-options
I have been wondering about the same issue. After reading this ticket I did some testing.
See video attached which shows the inconsistencies in delay, sometimes it responds fast, sometimes slower, sometimes not at all.
The physical button on this nspanel send out an MQTT messages to toggle the remote light above me and as you can see it always shows an "instant" response which proves it is not a WIFI issue. Deactivating screensaver and dialling through the interface cards has a lot of delay in comparison and the delay is not very consistent, e.g. shows a response time between between 0.5-2 seconds.
I also experience bugs (rarely but consistent) like,
I also looked at real-time logs from appdeamon and noticed that processing seems to be very fast with no considerable delay. Given the fact that the physical buttons activate a remote light instantly, I would say most of the delays are caused by the UI rendering and touch event processing. Using uvloop variable in appdaemon config had no effect in my setup.
Correct me if you have different insights. Thanks for the good work anyway!
I updated from version 47 to 50 an hour ago and the difference feels huge. In comparisson to the former version it's now closly 2 secconds of response after touching.
I updated from version 47 to 50 an hour ago and the difference feels huge. In comparisson to the former version it's now closly 2 secconds of response after touching.
What is the version 47 and 50 in reference to? I seem to have performance issues also and wondering how to fix. Or am I reading your post incorrect, and you said version 50 caused slow performance? I realize this is a couple months old so probably changed now?
I am having similar issues with the latest version. Sometimes it takes several seconds for something to happen.
I'm have the same issue. Sometimes it's slow to respond or doesn't respond when waking the screen. I can press the left/right buttons while this is occurring and those events fire immediately. Thoughts?
What would be needed to track this down? I'm happy to capture logs and test as necessary. When passing by the panel and want to make a change, if it takes more than a few seconds, I find I just pull out my phone.
From my testing it looks like the issue is with asyncio in python and how it is used in appdaemon (it can take really long time for it to actually process the event, uvloop seems to be slightly better, but not significantly as the real issue is with python limitations and how appdeamon makes thigs worse)
fixed by #1058
I'm experiencing a relatively high latency when i touch the screen.
I've narrowed it down to somewhere around appdaemon + nspanel-lovelace-ui app
comms from nspanel to MQTT broker (i've removed not relevant packets)
comms from mqtt broker to appdaemon
appdaemon logs:
as can be seen there is a significant latency between mqtt message being delivered by the broker to appdaemon and message appearing in the logs (so appdaemon reacting to it)
HA VM is not overloaded in any way