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

(HA_)MQTT sink broken if env UPDATEFREQ is set #16

Closed sti0 closed 1 year ago

sti0 commented 1 year ago

Hi, I'm trying to use smahub to get the values of my SMA HM2 and Tripower X into Home Assistant.

I can get the data when setting TRIPOWERX_ENABLED , SHM2_ENABLED and MQTT_ENABLED to true. But if I try to get the data through HA discovery (setting HA_MQTT_ENABLED to true) this won't work.

So i created a minimal configuration to test the behaviour but even when I only activate HA MQTT and the DEMOSOURCE the HA MQTT is not loaded.

This is my -minimal- config:

services:
  smahub:
    image: ghcr.io/anotherdaniel/smahub:v1.3.2
    container_name: smahub
    restart: unless-stopped
    environment:
      -  DEMOSOURCE_ENABLED=true
      -  SMAHUB_VERBOSER=true
      -  TRIPOWERX_ENABLED=false
      -  MQTT_ENABLED=false
      -  SHM2_ENABLED=false
      -  HA_MQTT_ENABLED=true
      -  HA_MQTT_ADDRESS=<ip>
      -  HA_MQTT_PORT=1883
      -  HA_MQTT_USER=<user>
      -  HA_MQTT_PASSWORD=<pass>
      -  HA_MQTT_PREFIX=homeassistant
      -  HA_MQTT_UPDATEFREQ=10

Container log:

2023-10-21 18:09:58 DEBUG    Verbose output enabled
2023-10-21 18:09:58 DEBUG    Found .conf file for EVCharger plugin
2023-10-21 18:09:58 DEBUG    Found .py file for EVCharger plugin
2023-10-21 18:09:58 DEBUG    Found .conf file for SHM2 plugin
2023-10-21 18:09:58 DEBUG    Found .py file for SHM2 plugin
2023-10-21 18:09:58 DEBUG    Found .conf file for TripowerX plugin
2023-10-21 18:09:58 DEBUG    Found .py file for TripowerX plugin
2023-10-21 18:09:58 DEBUG    Found .conf file for demo plugin
2023-10-21 18:09:58 DEBUG    Found .py file for demo plugin
2023-10-21 18:09:58 DEBUG    Found .conf file for demo plugin
2023-10-21 18:09:58 DEBUG    Found .py file for demo plugin
2023-10-21 18:09:58 DEBUG    Found .conf file for gen_ha_sensors plugin
2023-10-21 18:09:58 DEBUG    Found .py file for gen_ha_sensors plugin
2023-10-21 18:09:58 DEBUG    Found .conf file for ha_mqtt plugin
2023-10-21 18:09:58 DEBUG    Found .py file for ha_mqtt plugin
2023-10-21 18:09:58 DEBUG    Found .conf file for mqtt plugin
2023-10-21 18:09:58 DEBUG    Found .py file for mqtt plugin
2023-10-21 18:09:59 INFO     EV Charger plugin disabled
2023-10-21 18:09:59 INFO     SHM2 plugin disabled
2023-10-21 18:09:59 INFO     Tripower X plugin disabled
2023-10-21 18:09:59 INFO     Starting demo source
2023-10-21 18:09:59 INFO     demo sink plugin disabled
2023-10-21 18:09:59 INFO     gen_ha_sensors sink plugin disabled
2023-10-21 18:09:59 INFO     MQTT sink plugin disabled
sti0 commented 1 year ago

The issue comes from - HA_MQTT_UPDATEFREQ=10. If I don't set an update frequence it is working. But same for MQTT. If setting the update frequency MQTT is not working.

Tried all different ways to pass the value - HA_MQTT_UPDATEFREQ=10, - HA_MQTT_UPDATEFREQ="10", - HA_MQTT_UPDATEFREQ='10', none of them are working.

AnotherDaniel commented 1 year ago

Thank you very much for raising this, and for the debug input! I am looking into this now, found out that the update-freq thing also is broken for the TripowerX source plugin. On it...

AnotherDaniel commented 1 year ago

Ok, I've found an issue and did a v1.4 release which fixes that. Please try that, I would like to know if it solves the issue for you.

sti0 commented 1 year ago

Can confirm that that the Tripower source and the update frequence for this source is working in v1.4.

Thank you for the quick fix!