Add include/exclude homeassistant entities filtering for state sync
Currently all states are synced with HA. In my opinion it is waste of processor time, as in many case only few states are needed to make automations work. In my case syncing is causing constant load of 5% and 100% for 30s every 5min (resync of all states) on Dell WYSE terminal.
My proposition is to include some include/exclude filters on HA sensor names to specify, what states should be synced with appdaemon.
AppDaemon caches the states to make them available for dashboard, without that, the dash would either have to go to hass (cross site scripting issues) or force AD to call through to hass for every read, and proxy the updates.
But anyway for dashboard as well we don't need to cache them all, correct?
Probably not ...
there is no difference between using dashboard and AD. dashboard gets the states from AD and not from HA.
a filter on entities could be made possible for situations where people run AD on extreme weak devices. but i run AD on a PI zero, with around a thousand entities without any performance issues.
if AD causes a 100% CPU load for 30 secs every 5 minutes then that is not caused by cashing the states from entities. AD gets every state change at the moment that the state changes, and only checks if everything is still correct every 10 minutes.
so i think you got another problem somewhere causing that high CPU usage.
I have some old dell WYSE terminal. Processor usage is as per attachment. You can see, that every 5 min there is a spike, where appdaemon is syncing state (default is 5min as per documentation, not 10).
Thanks to that I could lower constant load and reduce spikes, so I will be able to lower CPU temp.
i can see there is a spike that is less then 20% and i dont know where in the docs you found its 5 mins, but i always knew it is 10 mins, and when i look into the code i see that its set to 600 secs. (isnt that 10 mins?)
so unless you can provide some sort of debug log that shows that it is AD syncing its state at the times from the spike, i am not convinced that is what is going on.
is this graph from AD without any apps?
not to mention that probably the load for AD will be way higher when AD tries to sync a bunch of independent entities then from just 1.
the change you ask would be like replacing:
a = self.get_state()
if a != b:
b = a
with
for entity in entitylist:
a = self.get_state(entity)
if a != b.entity:
b = a
with a slow connection from AD to HA, the second option probably will already be way worse with only 2 entities.
Hi. I partially see your point. So I did some measurement. First part of graph is with AD on, second one off. I see, that AD is causing some constant load and additionally high spikes every 5 min, higher than if AD is off.

the only thing i see is that you got some devices that cause a load every 5 mins, and that when you also got AD working, the load is higher.!
which is very obvious. because every state change in HA also causes a statechange in AD. if that wasnt the case, then there would be no interaction between HA and AD at all.
the amount that is used, also depends on what you do with it. if i got 10 apps that do something when a motion sensor changes state, then i will see i spike that is way higher when then sensor changes state, as when i dont do anything when the state changes.
so if you want to see the clear difference, then you need to make 2 graphs:
- with HA and AD running (without any apps running and without any dashboards connected)
- with only HA running.
if you then see spikes in the first 1, that you dont see in he second 1, you can assume its caused by AD.
for now i can only say: your spikes are caused by HA and not by AD. but off course if you add AD to HA the spikes will be higher.
I identified source of the problem - my thermostats were generating a lot of zigbee traffic, causing many state updates on HA side and then on AD side. When AD was disabled, load was not significant, but with AD on it raised.
Issue is not valid anymore.
glad you found out the problem.
and like i said, AD multiplies the used sources that are used in HA. which is only logical.
We will be adding this functionality in a new version of the mass plugin soon.