AnotherDaniel / smahub

SMAHub is a flexible and modular solution for collecting data from SMA photovoltaic (PV) products and publishing it to various output channels, such as MQTT.
GNU General Public License v2.0
30 stars 11 forks source link

Feature Request: Update Frequency for SHM2 #17

Closed sti0 closed 10 months ago

sti0 commented 1 year ago

As the other sources have a update frequency, I would expect the same for SHM2 source. I noticed HA instabillity issues because it refreshs the 60+ entities every second. After deactivating the most of them it becomes stable again (only activated power consumption and power supply).

Would be good if we could set a update frequency rate for SHM2 source as well.

AnotherDaniel commented 1 year ago

Hi @sti0, hm ok this seems to be related to the overall power of the system running your home assistant instance. Fyi, the main difference between SHM2 and other SMA sources used in smahub is, the SHM2 devices send out data frames by themselves (broadcast), every second. Things like the TripowerX inverter plugin do active polling of the web interface - so that is why SHM2 does not have a update frequency parameter at the moment, while the others do.

There are two ways I can think about this:

I will think about this a bit, I'm tending towards the filtering approach at the moment from a usefullness PoV, while the 'dropping data' approach would be a lot quicker to implement.

sti0 commented 1 year ago

Personally I would suggest to implement a logic to let the user choose. Some might need changes every seconds, others like the changes every 10s. Another downside of pushing every change is that the HA database grows insanely. I deactivated the recorder component for the SHM2. I know that the SHM2 works with broadcast but you can easily solve this by allow a updatefreq for mqtt publishing.

Just another note for the technical entities that "no one needs". You can just publish them as deactivated sensors to HA by default. This will allow the user to activate them if needed. So might only activate the most relevant ones and deactivate all others.

Again, this will put the user into the driver seat.

Looking forward for further development.

AnotherDaniel commented 1 year ago

The publishing side (sink plugins for mqtt and ha_mqtt) do have updateFreq settings, actually - would those help solve your issue immediately?

Do you have a documentation pointer for publishing sensors as deactivated? I seem to be googling it wrong...

sti0 commented 1 year ago

It doesn't. I already set the HA_MQTT frequency to 60s but assumed that it just refreshes everything (like the docs point out). But all incoming changes are published directly.

It think this should point out how to disable the entities: https://developers.home-assistant.io/docs/entity_registry_disabled_by

AnotherDaniel commented 12 months ago

Alright, I've just released v1.5 which brings an updateFreq for the SHM2 plugin, as well as a switch in the TripowerX and SHM2 plugin sensor dictionaries to enable/disable sensors (disabling will prevent them from being published by the ha_mqtt plugin). I've disabled all the phase-specific datapoints, the rest is enabled by default.

I'm not a deep pro with homeassistant - but the entity disabling probably will not be doable from a smahub perspective: smahub doesn't do it's own HA integration, but uses the existing MQTT one. Plus, the ha_mqtt plugin uses an existing library that publishes data in a form that HA MQTT autodiscovery understands, and that library doesn't seem to have any switches for disabling sensors (at least not that I can see).

I'd be interested to learn whether this update solves your request. I need to update the docs soon...

AnotherDaniel commented 10 months ago

No further feedback, assuming feature works as desired