bohdan-s / SunGather

GNU General Public License v3.0
141 stars 57 forks source link

Problems publishing collected data via MQTT #186

Open hwinkelmann opened 3 weeks ago

hwinkelmann commented 3 weeks ago

Hi,

I am struggling with the export of the harvested data via MQTT to home assistant. The data collection works nicely, in the web UI, i get a nice list of address registers and values, and the data is looking good, including the serial number. However, pushing that data to mosquitto fails.

I could post the entire debug log, but a whole lot deals with the state machine collecting the modbus data, which is obviously working fine. So I've reverted to the info log level, if that's not enough i'm happy to provide the debug log.

/sungather.py:139: SyntaxWarning: invalid escape sequence '\{'
  logging.info(f"Loading Export: exports\{export.get('name')}")
2024-06-08 11:33:04 INFO     Starting SunGather 0.5.2
2024-06-08 11:33:04 INFO     Need Help? https://github.com/bohdan-s/SunGather
2024-06-08 11:33:04 INFO     NEW HomeAssistant Add-on: https://github.com/bohdan-s/hassio-repository
2024-06-08 11:33:04 INFO     Loaded config: /share/SunGather/config.yaml
2024-06-08 11:33:05 INFO     Loaded registers: registers-sungrow.yaml
2024-06-08 11:33:05 INFO     Registers file version: 0.2.4
2024-06-08 11:33:05 INFO     Logging to console set to: INFO
2024-06-08 11:33:05 INFO     Loading SungrowClient 0.1.0
2024-06-08 11:33:05 INFO     Modbus client is not connected, attempting to reconnect
2024-06-08 11:33:05 INFO     Connection: ModbusTcpClient(10.0.0.158:502)
2024-06-08 11:33:08 WARNING  Modbus connection failed
Modbus connection failed
2024-06-08 11:33:08 INFO     Model detection failed, please set model in config.py
2024-06-08 11:33:09 WARNING  ModbusTcpClient(10.0.0.158:502): Connection unexpectedly closed 1.480055 seconds into unbounded read after returning 29 bytes
ModbusTcpClient(10.0.0.158:502): Connection unexpectedly closed 1.480055 seconds into unbounded read after returning 29 bytes
2024-06-08 11:33:09 INFO     Detected Serial: A22A050910
2024-06-08 11:33:09 INFO     Closing Session: ModbusTcpClient(10.0.0.158:502)
2024-06-08 11:33:09 INFO     Loading Export: exports\webserver
2024-06-08 11:33:09 INFO     Webserver: Configured
2024-06-08 11:33:09 INFO     Loading Export: exports\mqtt
2024-06-08 11:33:09 ERROR    Failed loading export: 'NoneType' object has no attribute 'replace'
                 Please make sure mqtt.py exists in the exports folder
Failed loading export: 'NoneType' object has no attribute 'replace'
                 Please make sure mqtt.py exists in the exports folder
2024-06-08 11:33:09 INFO     Modbus, Connecting new session
2024-06-08 11:33:09 INFO     Setting Initial Daily registers; daily_export_to_grid, daily_import_from_grid, last_reset
2024-06-08 11:33:09 INFO     Inverter: Successfully scraped in 0.8014 secs
2024-06-08 11:33:09 WARNING  MQTT: Server Error; Server not configured
MQTT: Server Error; Server not configured
2024-06-08 11:33:09 INFO     Closing Session: ModbusTcpClient(10.0.0.158:502)
2024-06-08 11:33:09 INFO     Next scrape in 29 secs

I am no python dev, but the first line looks like a syntax error?

The addon's config looks like this:

host: 10.0.0.158
timeout: 10
scan_interval: 30
connection: modbus
smart_meter: false
custom_mqtt_server: false
log_console: INFO
model: SH6.0RT

If you have any questions, please let me know! And thanks for your work!

michbeck100 commented 3 weeks ago

I’ve seen this error mostly when mosquitto doesn’t run before sungather starts or gets restarted. Sungather misses some resilience here.

hwinkelmann commented 3 weeks ago

I've disabled sungather and restarted the system and home assistant. Once mosquitto was up, I've started sungarher again. But the log looks still as above, so I assume it must be something else 😕

hwinkelmann commented 3 weeks ago

Misclicked, sorry