### Install SunGather Locally Source: https://context7.com/bohdan-s/sungather/llms.txt Commands to clone the repository, install dependencies, and initialize the configuration file. ```bash # Clone the repository git clone https://github.com/bohdan-s/SunGather.git cd SunGather # Install Python dependencies pip3 install --upgrade -r requirements.txt # Copy example config and customize cd SunGather cp config-example.yaml config.yaml # Run SunGather python3 sungather.py ``` -------------------------------- ### Install and Run SunGather Locally Source: https://github.com/bohdan-s/sungather/blob/main/docs/index.md Commands to clone the repository, install dependencies, and execute the application. ```sh git clone https://github.com/bohdan-s/SunGather.git cd SunGather pip3 install --upgrade -r requirements.txt ``` ```sh copy config-example.py config.py ``` ```sh python3 sungather.py ``` -------------------------------- ### Configure SunGather Source: https://github.com/bohdan-s/sungather/blob/main/README.md Command to create the configuration file from the provided example. ```sh cd SunGather copy config-example.yaml config.yaml ``` -------------------------------- ### Clone and Install SunGather Source: https://github.com/bohdan-s/sungather/blob/main/README.md Commands to clone the repository and install the necessary Python dependencies. ```sh git clone https://github.com/bohdan-s/SunGather.git cd SunGather pip3 install --upgrade -r requirements.txt ``` -------------------------------- ### Configure Inverter Settings Source: https://context7.com/bohdan-s/sungather/llms.txt Example YAML configuration for connecting to a Sungrow inverter. ```yaml # config.yaml inverter: host: 192.168.1.100 # [Required] IP Address of the Inverter or Dongle port: 502 # [Optional] Default for modbus is 502, for http is 8082 timeout: 10 # [Optional] Default is 10, how long to wait for a connection retries: 3 # [Optional] Default is 3, how many times to retry if connection fails slave: 0x01 # [Optional] Default is 0x01 scan_interval: 30 # [Optional] Default is 30 seconds connection: modbus # [Required] options: modbus, sungrow, http # model: "SG7.0RT" # [Optional] Autodetected on startup # serial: xxxxxxxxxx # [Optional] Autodetected on startup smart_meter: True # [Optional] Set true if you have a smart meter installed use_local_time: False # [Optional] Use PC time instead of inverter time log_console: INFO # [Optional] Options: DEBUG, INFO, WARNING, ERROR log_file: DEBUG # [Optional] Options: OFF, DEBUG, INFO, WARNING, ERROR level: 1 # [Optional] Data detail level: 0=basic, 1=useful, 2=full, 3=all registers ``` -------------------------------- ### InfluxDB Query Example Source: https://context7.com/bohdan-s/sungather/llms.txt Example Flux query to retrieve data from InfluxDB. This query filters data for the last 24 hours, specifically for the 'power' measurement and 'total_active_power' field. ```flux from(bucket: "SunGather") |> range(start: -24h) |> filter(fn: (r) => r._measurement == "power") |> filter(fn: (r) => r._field == "total_active_power") ``` -------------------------------- ### MQTT Payload Structure Source: https://context7.com/bohdan-s/sungather/llms.txt Example of the JSON data structure published to the MQTT broker. ```json { "host": "192.168.1.100", "model": "SG7.0RT", "serial": "A123456789", "daily_power_yields": 15.2, "total_active_power": 4500, "internal_temperature": 35.2, "timestamp": "2024-01-15 14:30:00" } ``` -------------------------------- ### Configure Smart Meter in SunGather Source: https://github.com/bohdan-s/sungather/blob/main/docs/index.md Set `smart_meter: True` in your SunGather config.yaml if you have a smart meter installed. This enables the tool to read power usage from the meter box. ```yaml smart_meter: True ``` -------------------------------- ### Configure Basic MQTT Export Source: https://context7.com/bohdan-s/sungather/llms.txt Set up MQTT publishing for integration with home automation systems. ```yaml exports: - name: mqtt enabled: True host: 192.168.1.200 # [Required] MQTT Server IP or hostname port: 1883 # [Optional] Default 1883, use 8883 for TLS topic: "SunGather/{serial_number}" # [Optional] Default topic pattern username: mqtt_user # [Optional] If MQTT server requires auth password: mqtt_password # [Optional] If MQTT server requires auth client_id: sungather_client # [Optional] Defaults to serial number homeassistant: False # [Optional] Enable HA auto-discovery ``` -------------------------------- ### Build Multi-Architecture Docker Images Source: https://github.com/bohdan-s/sungather/blob/main/README.md Use these commands to set up BuildX and build images for multiple platforms including Raspberry Pi. ```sh docker run --privileged --rm tonistiigi/binfmt --install all docker buildx create --platform linux/amd64,linux/arm64/v8 --use docker buildx build --push --platform linux/amd64,linux/arm64/v8 -t bohdans/sungather:latest -t bohdans/sungather:v . ``` -------------------------------- ### Configure MQTT and Home Assistant AutoDiscovery Source: https://github.com/bohdan-s/sungather/blob/main/README.md Enable MQTT output and Home Assistant integration in the configuration file. ```yaml - name: mqtt enabled: True host: 192.168.1.200 homeassistant: True ``` -------------------------------- ### Build Docker Image for Current Architecture Source: https://github.com/bohdan-s/sungather/blob/main/README.md Standard build and push commands for the current host architecture. ```sh docker build --no-cache --rm -t bohdans/sungather:latest -t bohdans/sungather:v . docker push bohdans/sungather -a ``` -------------------------------- ### Run SunGather via Command Line Source: https://context7.com/bohdan-s/sungather/llms.txt Common command-line arguments for testing, configuration overrides, and automation. ```bash # Show help python3 sungather.py -h # Use custom config file python3 sungather.py -c /full/path/config.yaml # Use custom registers file python3 sungather.py -r /full/path/registers-sungrow.yaml # Set logging level (10=Debug, 20=Info, 30=Warning, 40=Error) python3 sungather.py -v 20 # Run once and exit (useful for cron jobs) python3 sungather.py --runonce # Full example with multiple options python3 sungather.py -c /etc/sungather/config.yaml -v 20 --runonce ``` -------------------------------- ### Run SunGather via Command Line Source: https://github.com/bohdan-s/sungather/blob/main/README.md Execute the script with a custom configuration file path. ```sh python3 sungather.py -c /full/path/config.yaml ``` -------------------------------- ### Configure Home Assistant MQTT Auto-Discovery Source: https://context7.com/bohdan-s/sungather/llms.txt Enable automatic sensor discovery in Home Assistant with custom sensor definitions. ```yaml exports: - name: mqtt enabled: True host: 192.168.1.200 homeassistant: True ha_sensors: - name: "Daily Generation" sensor_type: sensor register: daily_power_yields device_class: energy state_class: total_increasing icon: "mdi:solar-power" - name: "Daily Export to Grid" sensor_type: sensor register: daily_export_to_grid device_class: energy state_class: total_increasing icon: "mdi:transmission-tower-export" value_template: "{{ value_json.daily_export_to_grid | round(2) }}" last_reset_value_template: "{{ value_json.last_reset }}" - name: "Daily Import from Grid" sensor_type: sensor register: daily_import_from_grid device_class: energy state_class: total_increasing icon: "mdi:transmission-tower-import" - name: "Temperature" sensor_type: sensor register: internal_temperature device_class: temperature state_class: measurement - name: "Power State" sensor_type: binary_sensor register: run_state device_class: running payload_on: "ON" payload_off: "OFF" - name: "Active Generation" sensor_type: sensor register: total_active_power dev_class: power state_class: measurement - name: "Active Export to Grid" sensor_type: sensor register: export_to_grid dev_class: power state_class: measurement - name: "Active Import from Grid" sensor_type: sensor register: import_from_grid dev_class: power state_class: measurement ``` -------------------------------- ### Configure Smart Meter for SG Models Source: https://github.com/bohdan-s/sungather/blob/main/README.md Enable the smart meter setting in the configuration file for SG series models. ```yaml # Only for SG* Models smart_meter: True ``` -------------------------------- ### Deploy SunGather via Docker Source: https://context7.com/bohdan-s/sungather/llms.txt Command to run the SunGather container with necessary volume mounts and environment variables. ```bash # Pull the Docker image docker pull bohdans/sungather # Run the container docker run -d --name sungather \ --restart always \ -v /path/to/config.yaml:/config/config.yaml \ -v /path/to/logs:/logs \ -e TZ=Australia/Sydney \ -p 8080:8080 \ bohdans/sungather ``` -------------------------------- ### Configure Home Assistant Energy Dashboard Sensors Source: https://context7.com/bohdan-s/sungather/llms.txt Enable MQTT with HA discovery in SunGather's config.yaml to automatically populate sensors in Home Assistant for energy tracking. ```yaml exports: - name: mqtt enabled: True host: 192.168.1.200 homeassistant: True ha_sensors: - name: "Daily Generation" sensor_type: sensor register: daily_power_yields device_class: energy state_class: total_increasing - name: "Daily Import from Grid" sensor_type: sensor register: daily_import_from_grid device_class: energy state_class: total_increasing - name: "Daily Export to Grid" sensor_type: sensor register: daily_export_to_grid device_class: energy state_class: total_increasing ``` -------------------------------- ### Enable Built-in Web Server Source: https://context7.com/bohdan-s/sungather/llms.txt Configure the web server export module to expose inverter data via browser or API. ```yaml exports: - name: webserver enabled: True port: 8080 # [Optional] Default is 8080 ``` -------------------------------- ### Enable Console Export Source: https://context7.com/bohdan-s/sungather/llms.txt Configuration snippet to enable console output for data verification. ```yaml exports: - name: console enabled: True ``` -------------------------------- ### Configure PVOutput Integration Source: https://context7.com/bohdan-s/sungather/llms.txt Configure the PVOutput integration to upload solar generation data. Required parameters include your PVOutput API key and System ID. Optional parameters allow for rate limiting and data parameter mapping. ```yaml exports: - name: pvoutput enabled: True api: "your-pvoutput-api-key" # [Required] API Key from Settings > API Key sid: "12345" # [Required] System ID from Settings > Registered Systems join_team: True # [Optional] Join SunGather team on PVOutput rate_limit: 60 # [Optional] 60 for regular, 300 for donation accounts cumulative_flag: 2 # [Optional] 1=v1&v3 lifetime, 2=v1 daily totals, 3=v3 lifetime batch_points: 1 # [Optional] How many points to batch (1-12) parameters: - name: v1 # Energy Generation (Wh) register: daily_power_yields multiple: 1000 # Convert kWh to Wh - name: v2 # Power Generation (W) register: total_active_power - name: v4 # Power Consumption (W) register: load_power - name: v6 # Voltage (V) register: phase_a_voltage ``` -------------------------------- ### Run SunGather via Docker Source: https://github.com/bohdan-s/sungather/blob/main/README.md Commands to pull the Docker image and run the container with volume and environment configurations. ```sh docker pull bohdans/sungather docker run -d --name sungather \ --restart always \ -v {path to}/config.yaml:/config/config.yaml \ -v {logpath}:/logs \ -e TZ=Australia/Sydney \ -p 8080:8080 \ bohdans/sungather ``` -------------------------------- ### Run SunGather Source: https://github.com/bohdan-s/sungather/blob/main/README.md Command to execute the main Python script. ```sh python3 sungather.py ``` -------------------------------- ### Home Assistant Riemann Sum Integration Source: https://github.com/bohdan-s/sungather/blob/main/docs/index.md Configure these sensors in your `sensors.yaml` file to convert power (W) reported by the inverter into energy (Wh) for Home Assistant. This is necessary for accurate energy tracking and reporting. ```yaml sensor: - platform: integration source: sensor.inverter_active_power name: Solar Production (Sungather) - platform: integration source: sensor.inverter_export_to_grid name: Return to Grid (Sungather) - platform: integration source: sensor.inverter_import_from_grid name: Grid Consumption (Sungather) ``` -------------------------------- ### Configure InfluxDB v2.x Export Source: https://context7.com/bohdan-s/sungather/llms.txt Set up direct metric writing to InfluxDB v2.x using API tokens and organization settings. ```yaml exports: - name: influxdb enabled: True url: "http://localhost:8086" # [Optional] Default URL token: "your-influxdb-api-token" # [Required] API Token for v2.x org: "Default" # [Required] InfluxDB Organization bucket: "SunGather" # [Required] InfluxDB Bucket name measurements: - point: "power" register: daily_power_yields - point: "power" register: total_active_power - point: "power" register: load_power - point: "power" register: meter_power - point: "power" register: export_to_grid - point: "power" register: import_from_grid - point: "temp" register: internal_temperature ``` -------------------------------- ### Access Web Server Endpoints Source: https://context7.com/bohdan-s/sungather/llms.txt Interact with the web server using curl to retrieve dashboard, JSON, or Prometheus metrics. ```bash # HTML dashboard (auto-refreshes every 15 seconds) curl http://localhost:8080/ # JSON API endpoint curl http://localhost:8080/json # Output: # { # "registers": { # "5003": {"register": "daily_power_yields", "value": "15.2", "unit": "kWh"}, # "5031": {"register": "total_active_power", "value": "4500", "unit": "W"} # }, # "client_config": {"host": "192.168.1.100", "port": "502"}, # "inverter_config": {"model": "SG7.0RT", "serial": "A123456789"} # } # Prometheus metrics endpoint curl http://localhost:8080/metrics # Output: # daily_power_yields{address="5003", unit="kWh"} 15.2 # total_active_power{address="5031", unit="W"} 4500 # internal_temperature{address="5008", unit="°C"} 35.2 ``` -------------------------------- ### Configure Inverter Data Detail Level Source: https://context7.com/bohdan-s/sungather/llms.txt Configure the data detail level for inverter data collection. Level 1 is the default and includes all data required for exports. Higher levels collect more detailed information. ```yaml inverter: host: 192.168.1.100 connection: modbus level: 1 # Set data detail level # Level 0: Minimal - Model info and basic solar generation # - daily_power_yields # - total_active_power # - timestamp # Level 1: Useful (Default) - All data required for exports # - All Level 0 registers # - total_power_yields, total_running_time # - internal_temperature, phase_a_voltage # - meter_power, load_power (if smart_meter enabled) # - Battery registers for hybrid models # Level 2: Full - Everything your inverter supports # - All Level 1 registers # - All MPPT voltages and currents ``` -------------------------------- ### Configure InfluxDB v1.8 Export Source: https://context7.com/bohdan-s/sungather/llms.txt Set up InfluxDB v1.8 export with username and password authentication. Ensure the URL, username, password, and bucket are correctly configured for your InfluxDB instance. ```yaml exports: - name: influxdb enabled: True url: "http://localhost:8086" username: influx_user # [Required] Username for v1.8 password: influx_password # [Required] Password for v1.8 org: "Default" # [Required] Will be ignored for v1.8 bucket: "sungather_db" # [Required] Database name for v1.8 measurements: - point: "solar" register: daily_power_yields - point: "solar" register: total_active_power ``` -------------------------------- ### Home Assistant MQTT Sensors Source: https://github.com/bohdan-s/sungather/blob/main/docs/index.md These are the Home Assistant sensors automatically created by SunGather via MQTT auto-discovery. Ensure your MQTT broker is configured and accessible by both SunGather and Home Assistant. ```yaml sensor.inverter_active_power sensor.inverter_daily_generation sensor.inverter_export_to_grid sensor.inverter_import_from_grid sensor.inverter_load_power sensor.inverter_meter_power ``` -------------------------------- ### Hybrid Inverter Specific Registers Reference Source: https://context7.com/bohdan-s/sungather/llms.txt Reference for additional registers specific to SH* hybrid inverter models with battery storage. This includes battery status, charging/discharging power, and grid state information. ```yaml # Battery Registers (SH* Hybrid models) battery_power: # Battery charge/discharge power (W) - Address 13022 battery_level: # Battery state of charge (%) - Address 13023 battery_voltage: # Battery voltage (V) - Address 13020 battery_current: # Battery current (A) - Address 13021 battery_temperature: # Battery temperature (°C) - Address 13025 battery_state_of_healthy: # Battery health (%) - Address 13024 # Hybrid Power Flow load_power_hybrid: # Total load power (W) - Address 13008 export_power_hybrid: # Export power (W) - Address 13010 daily_battery_charge_from_pv: # Daily PV to battery (kWh) - Address 13012 # Grid State grid_state: # "On-grid" or "Off-grid" - Address 13030 system_state: # Run, Stop, Standby, Fault, etc. - Address 13000 ``` -------------------------------- ### Common Inverter Registers Reference Source: https://context7.com/bohdan-s/sungather/llms.txt Reference for common registers available on most Sungrow inverter models, including power, energy, temperature, and grid-related values. These registers are essential for monitoring solar generation. ```yaml # Power and Energy Registers daily_power_yields: # Daily energy generated (kWh) - Address 5003 total_power_yields: # Total energy since install (kWh) - Address 5004 total_active_power: # Current power generation (W) - Address 5031 internal_temperature: # Inverter internal temp (°C) - Address 5008 total_running_time: # Total operating hours - Address 5006 # Grid Registers (SG* models with smart meter) meter_power: # Power at meter box (W) - +ve=import, -ve=export load_power: # Total power consumption (W) export_to_grid: # Power being exported (W) import_from_grid: # Power being imported (W) # Voltage and Current phase_a_voltage: # Phase A voltage (V) - Address 5019 phase_b_voltage: # Phase B voltage (V) - Address 5020 phase_c_voltage: # Phase C voltage (V) - Address 5021 mppt_1_voltage: # MPPT 1 voltage (V) - Address 5011 mppt_1_current: # MPPT 1 current (A) - Address 5012 ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.