s-allius / tsun-gen3-proxy

This proxy enables a reliable connection between TSUN third generation inverters (eg. TSOL MS600, MS800, MS2000) and an MQTT broker to integrate the inverter into typical home automations.
https://s-allius.github.io/tsun-gen3-proxy/
BSD 3-Clause "New" or "Revised" License
53 stars 6 forks source link

Run as standalone client app #180

Open il-steffen opened 2 months ago

il-steffen commented 2 months ago

Thanks for your project!

My inverter powered up this morning and thanks to your project I was able to connect + setup wifi without (so far) having to go through TSUN/Orbit app registration stuff.

However I have HA and MQTT and many other things already running and I'm not a fan of "managing" applications with Docker. The new client mode also seems to make many things obsolete - I just need a client to poll the inverter and push the data to my favorite data base. One tool for one job.

I ran into a few issues trying to get this working and listed my detailed steps/problems below. Maybe this will be helpful for others or to improve the app. Also appreciate any comments if something can be done differently.

1. Attempt to install basic python app instead of Docker stuff

  1. python3 -m venv .venv; source .venv/bin/activate; pip -r requirements.txt
    1. app entry point at app/src/server.py, example config in app/config
    2. I got a Module not found tomllib - we seem to require >=python3.11
    3. next we die on logging: logging.config.fileConfig('logging.ini') - need to run from within app/src
    4. failed to open log/proxy.log - need to create log/
    5. failed to open default_config.toml, after copying this from ../config it tries to shutil.copy2() it to config/, then again fails to open and advises about renaming some example.toml. So actually we need to copy to app/src/config/config.toml...
    6. now it starts: cd app/src; python3 server.py

2. Configuration file...I think this could use some background to explain the purpose of each section

  1. reach tsun/solarman cloud....why do we care? just for FW updates?
  2. home assistant config could use 1-2 sentences background info as well. The comments sound like you're actually listening/checking on some HA status updates? Or is this actually just mqtt topics chosen so that they directly popup in HA?
  3. inverter mapping looks reasonable, although its not immediately clear which elements are important and how it relates to client_mode. After putting the inverter IP into client_mode I could see my TSUN MS2000 pop up in HA MQTT, so that's great. The other two default configured inverters didn't show up anywhere and the wrong serial number also didn't seem to matter...
  4. what does modbus_polling do? is this just for specific inverters, do we need special cabling, does it give us extra information or alternative way to access the device instead of wifi/proxy?
  5. pv=...seems to be cosmetic / info strings only. can we disable a pv entry if a panel port is unused?
  6. acl....these are more clear after seeing the wiki reference info. it seems more like a low-level / expert config setting. I guess it is not relevant for client_mode or when the tsun/solarman cloud connection is not enabled?

Need to play around some more...to be continued..

Edit: More reference info in the project wiki - the inverter config clauses are more clear now and base AT/modbus documentation is great!

s-allius commented 2 months ago

Hi il-steffen,

thank you for your great feedback. I will have a deep look at it at the weekend and will use it for improvements...

Cheers Stefan

s-allius commented 1 month ago

Hi il-steffen,

at the start of the project I had decided to publish this project only as a Docker image. This way I avoid dependency issues as the container contains everything that is needed. For development, I always use the latest Phython release (currently 3.12.5), which also runs all unit tests. I don't bother with older versions, as I don't think this is necessary for containerization.

Configuration

2.1 You are right, you only need this for updates or if you want to use the TSUN apps. From a security point of view, it would be better not to configure these connections, as this sends a lot of data to TSUN (e.g. the network configuration, ...)

2.2 Yes, I listen for the Home Assistant status in these MQTT topics. When the status changes to online, I register all devices with Home Assistant. With this approach, I don't need to send topics as retaining messages. This avoids a lot of problems

2.3 At the moment, you only need to configure the IP address and the port in 'Client Mode' (if it is not the default value 8899). The rest is for later proxy versions, or when not using Client Mode. For example, we could implement a connection to the TSUN Cloud even if the inverter is running in Client Mode. Then we can filter critical information like WiFi password, which is not possible with an SSL connection to TSUN.

2.4 Modbus pollingis for inverters which are connected in server mode to get information faster from the device. In server mode the inverter sends data only every 5 minutes. With the polling you get data every 60 seconds. The client mode use the Modbus polling automatically, since the inverter doesn't send any data in this mode. The data polling time is about 30 seconds then. See also: https://github.com/s-allius/tsun-gen3-proxy/wiki/Operation-Modes-Overview

il-steffen commented 1 month ago

Too sunny for work today but if you're open to it, I would take a shot at offering a pip install option as well. Should also work fine with CI.


From: Stefan Allius @.***> Sent: Saturday, September 7, 2024 15:12 To: s-allius/tsun-gen3-proxy Cc: Schulz, Steffen; Author Subject: Re: [s-allius/tsun-gen3-proxy] Run as standalone client app (Issue #180)

Hi il-steffen,

at the start of the project I had decided to publish this project only as a Docker image. This way I avoid dependency issues as the container contains everything that is needed. For development, I always use the latest Phython release (currently 3.12.5), which also runs all unit tests. I don't bother with older versions, as I don't think this is necessary for containerization.

Configuration

2.1 You are right, you only need this for updates or if you want to use the TSUN apps. From a security point of view, it would be better not to configure these connections, as this sends a lot of data to TSUN (e.g. the network configuration, ...)

2.2 Yes, I listen for the Home Assistant status in these MQTT topics. When the status changes to online, I register all devices with Home Assistant. With this approach, I don't need to send topics as retaining messages. This avoids a lot of problems

2.3 At the moment, you only need to configure the IP address and the port in 'Client Mode' (if it is not the default value 8899). The rest is for later proxy versions, or when not using Client Mode. For example, we could implement a connection to the TSUN Cloud even if the inverter is running in Client Mode. Then we can filter critical information like WiFi password, which is not possible with an SSL connection to TSUN.

2.4 Modbus pollingis for inverters which are connected in server mode to get information faster from the device. In server mode the inverter sends data only every 5 minutes. With the polling you get data every 60 seconds. The client mode use the Modbus polling automatically, since the inverter doesn't send any data in this mode. The data polling time is about 30 seconds then. See also: https://github.com/s-allius/tsun-gen3-proxy/wiki/Operation-Modes-Overview

— Reply to this email directly, view it on GitHubhttps://github.com/s-allius/tsun-gen3-proxy/issues/180#issuecomment-2335183126, or unsubscribehttps://github.com/notifications/unsubscribe-auth/APUTDH4LBYKKYZYFF2FM6J3ZVL3TTAVCNFSM6AAAAABNQAGVF2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMZVGE4DGMJSGY. You are receiving this because you authored the thread.Message ID: @.***> Intel Deutschland GmbH Registered Address: Am Campeon 10, 85579 Neubiberg, Germany Tel: +49 89 99 8853-0, www.intel.de Managing Directors: Sean Fennelly, Jeffrey Schneiderman, Tiffany Doon Silva Chairperson of the Supervisory Board: Nicole Lau Registered Office: Munich Commercial Register: Amtsgericht Muenchen HRB 186928

s-allius commented 1 month ago

Yes, with pleasure. I just made it easy for myself, as Phython and Docker were new territory for me. I didn't bother with modules and the Pip installation. A pip installation is certainly a welcome alternative for many, as Docker requires a lot of knowledge.

If you need help or have any questions, I'm here to help