{"id":35710775,"url":"https://github.com/sm26449/fronius-modbus-mqtt","last_synced_at":"2026-01-06T04:08:06.866Z","repository":{"id":327807817,"uuid":"1107185861","full_name":"sm26449/fronius-modbus-mqtt","owner":"sm26449","description":"Python application that reads data from Fronius inverters and smart meters via Modbus TCP and publishes to MQTT and/or InfluxDB.","archived":false,"fork":false,"pushed_at":"2025-12-05T21:59:19.000Z","size":58,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-12-09T11:39:44.762Z","etag":null,"topics":["docker","fronius","fronius-datamanager","fronius-inverter","influxdb","modbus-tcp","mqtt","python"],"latest_commit_sha":null,"homepage":"http://diysolar.ro","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sm26449.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-11-30T18:33:30.000Z","updated_at":"2025-12-05T21:59:23.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/sm26449/fronius-modbus-mqtt","commit_stats":null,"previous_names":["sm26449/fronius-modbus-mqtt"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/sm26449/fronius-modbus-mqtt","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sm26449%2Ffronius-modbus-mqtt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sm26449%2Ffronius-modbus-mqtt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sm26449%2Ffronius-modbus-mqtt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sm26449%2Ffronius-modbus-mqtt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sm26449","download_url":"https://codeload.github.com/sm26449/fronius-modbus-mqtt/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sm26449%2Ffronius-modbus-mqtt/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28221562,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2026-01-06T02:00:07.049Z","response_time":56,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","fronius","fronius-datamanager","fronius-inverter","influxdb","modbus-tcp","mqtt","python"],"created_at":"2026-01-06T04:08:04.911Z","updated_at":"2026-01-06T04:08:06.859Z","avatar_url":"https://github.com/sm26449.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Fronius Modbus MQTT\r\n\r\nPython application that reads data from Fronius inverters and smart meters via Modbus TCP and publishes to MQTT and/or InfluxDB.\r\n\r\n## Features\r\n\r\n- **SunSpec Protocol Support** - Full SunSpec Modbus implementation with scale factors\r\n- **Multi-Device Support** - Poll multiple inverters and smart meters\r\n- **MPPT Data** - Per-string voltage, current, and power (Model 160)\r\n- **Immediate Controls** - Read inverter control settings (Model 123)\r\n- **Event Parsing** - Decode Fronius event flags with human-readable descriptions\r\n- **Publish Modes** - Publish on change or publish all values\r\n- **Docker Support** - Separate containers for inverters and meters\r\n- **MQTT Integration** - Publish to any MQTT broker with configurable topics\r\n- **InfluxDB Integration** - Time-series database storage with batching and rate limiting\r\n\r\n## Quick Start\r\n\r\n### 1. Clone the Repository\r\n\r\n```bash\r\ngit clone https://github.com/sm26449/fronius-modbus-mqtt.git\r\ncd fronius-modbus-mqtt\r\n```\r\n\r\n### 2. Create Configuration\r\n\r\n```bash\r\n# Copy example config\r\ncp config/fronius_modbus_mqtt.example.yaml config/fronius_modbus_mqtt.yaml\r\n\r\n# Edit with your settings\r\nnano config/fronius_modbus_mqtt.yaml\r\n```\r\n\r\nMinimum configuration:\r\n```yaml\r\nmodbus:\r\n  host: 192.168.1.100      # Fronius DataManager IP\r\n\r\nmqtt:\r\n  enabled: true\r\n  broker: 192.168.1.100    # MQTT broker IP\r\n```\r\n\r\n### 3. Build Docker Images\r\n\r\n```bash\r\ndocker-compose build\r\n```\r\n\r\n### 4. Prepare Storage Directories\r\n\r\n**For local development/testing:**\r\n```bash\r\n# Create local storage directories\r\nmkdir -p storage/fronius-inverters/{config,data,logs}\r\nmkdir -p storage/fronius-meter/{config,data,logs}\r\n\r\n# Copy config files\r\ncp config/fronius_modbus_mqtt.yaml storage/fronius-inverters/config/\r\ncp config/fronius_modbus_mqtt.yaml storage/fronius-meter/config/\r\ncp config/registers.json storage/fronius-inverters/config/\r\ncp config/registers.json storage/fronius-meter/config/\r\ncp config/FroniusEventFlags.json storage/fronius-inverters/config/\r\ncp config/FroniusEventFlags.json storage/fronius-meter/config/\r\n```\r\n\r\n**For production deployment:**\r\n```bash\r\n# Use docker-compose.production.yml for absolute paths\r\ncp docker-compose.production.yml docker-compose.yml\r\n\r\n# Create directories on your server\r\nsudo mkdir -p /docker-storage/pv-stack/fronius-inverters/{config,data,logs}\r\nsudo mkdir -p /docker-storage/pv-stack/fronius-meter/{config,data,logs}\r\n\r\n# Copy config files\r\nsudo cp config/fronius_modbus_mqtt.yaml /docker-storage/pv-stack/fronius-inverters/config/\r\nsudo cp config/fronius_modbus_mqtt.yaml /docker-storage/pv-stack/fronius-meter/config/\r\nsudo cp config/registers.json /docker-storage/pv-stack/fronius-inverters/config/\r\nsudo cp config/registers.json /docker-storage/pv-stack/fronius-meter/config/\r\nsudo cp config/FroniusEventFlags.json /docker-storage/pv-stack/fronius-inverters/config/\r\nsudo cp config/FroniusEventFlags.json /docker-storage/pv-stack/fronius-meter/config/\r\n```\r\n\r\n### 5. Start Containers\r\n\r\n```bash\r\ndocker-compose up -d\r\n```\r\n\r\n### 6. Verify Operation\r\n\r\n```bash\r\n# Check container status\r\ndocker-compose ps\r\n\r\n# View inverter logs\r\ndocker logs -f fronius-inverters\r\n\r\n# View meter logs\r\ndocker logs -f fronius-meter\r\n```\r\n\r\n## Configuration Reference\r\n\r\n### General Settings\r\n\r\n```yaml\r\ngeneral:\r\n  log_level: INFO              # DEBUG, INFO, WARNING, ERROR\r\n  log_file: \"/app/logs/fronius.log\"  # Log file path\r\n  poll_interval: 5             # Seconds between polling cycles\r\n  publish_mode: changed        # 'changed' or 'all'\r\n```\r\n\r\n### Modbus Settings\r\n\r\n```yaml\r\nmodbus:\r\n  host: 192.168.1.100          # Fronius DataManager IP\r\n  port: 502                    # Modbus TCP port\r\n  timeout: 3                   # Connection timeout (seconds)\r\n  retry_attempts: 3            # Retries on failure\r\n  retry_delay: 0.5             # Delay between retries (seconds)\r\n```\r\n\r\n### Device Settings\r\n\r\n```yaml\r\ndevices:\r\n  inverters: [1, 2, 3, 4]      # Inverter Modbus IDs\r\n  meters: [240]                # Meter Modbus ID\r\n  inverter_poll_delay: 2       # Delay between device reads (seconds)\r\n  inverter_read_delay_ms: 500  # Delay between register blocks (ms)\r\n```\r\n\r\n### MQTT Settings\r\n\r\n```yaml\r\nmqtt:\r\n  enabled: true\r\n  broker: 192.168.1.100\r\n  port: 1883\r\n  username: \"\"                 # Optional authentication\r\n  password: \"\"\r\n  topic_prefix: fronius        # Base topic\r\n  retain: true                 # Retain messages\r\n  qos: 0                       # QoS level (0, 1, 2)\r\n```\r\n\r\n### InfluxDB Settings\r\n\r\n```yaml\r\ninfluxdb:\r\n  enabled: true\r\n  url: http://192.168.1.100:8086\r\n  token: \"your-influxdb-token\"\r\n  org: \"your-org\"\r\n  bucket: \"fronius\"\r\n  write_interval: 5            # Min seconds between writes per device\r\n  publish_mode: changed        # 'changed' or 'all'\r\n```\r\n\r\n**InfluxDB Setup:**\r\n1. Create a bucket named `fronius` in InfluxDB\r\n2. Create an API token with read/write permissions for the bucket\r\n3. Copy the token to your configuration\r\n\r\n## Command Line Options\r\n\r\n```bash\r\npython fronius_modbus_mqtt.py [OPTIONS]\r\n\r\nOptions:\r\n  -c, --config PATH    Path to configuration file\r\n  -d, --device TYPE    Device type to poll: all, inverter, or meter\r\n  -f, --force          Force start even if another instance is running\r\n  -v, --version        Show version\r\n```\r\n\r\n## Docker Commands\r\n\r\n```bash\r\n# Build images\r\ndocker-compose build\r\n\r\n# Build without cache (after code changes)\r\ndocker-compose build --no-cache\r\n\r\n# Start containers\r\ndocker-compose up -d\r\n\r\n# Stop containers\r\ndocker-compose down\r\n\r\n# Restart containers\r\ndocker-compose restart\r\n\r\n# View logs\r\ndocker logs -f fronius-inverters\r\ndocker logs -f fronius-meter\r\n\r\n# Check status\r\ndocker-compose ps\r\n```\r\n\r\n## MQTT Topics\r\n\r\n### Inverter Topics\r\n```\r\nfronius/inverter/{serial}/ac_power\r\nfronius/inverter/{serial}/dc_power\r\nfronius/inverter/{serial}/ac_voltage_an\r\nfronius/inverter/{serial}/ac_voltage_bn\r\nfronius/inverter/{serial}/ac_voltage_cn\r\nfronius/inverter/{serial}/ac_current\r\nfronius/inverter/{serial}/ac_frequency\r\nfronius/inverter/{serial}/lifetime_energy\r\nfronius/inverter/{serial}/status\r\nfronius/inverter/{serial}/events\r\nfronius/inverter/{serial}/mppt/1/voltage\r\nfronius/inverter/{serial}/mppt/1/current\r\nfronius/inverter/{serial}/mppt/1/power\r\nfronius/inverter/{serial}/mppt/2/voltage\r\nfronius/inverter/{serial}/mppt/2/current\r\nfronius/inverter/{serial}/mppt/2/power\r\n```\r\n\r\n### Meter Topics\r\n```\r\nfronius/meter/{serial}/power_total\r\nfronius/meter/{serial}/power_a\r\nfronius/meter/{serial}/power_b\r\nfronius/meter/{serial}/power_c\r\nfronius/meter/{serial}/voltage_an\r\nfronius/meter/{serial}/voltage_bn\r\nfronius/meter/{serial}/voltage_cn\r\nfronius/meter/{serial}/current_a\r\nfronius/meter/{serial}/current_b\r\nfronius/meter/{serial}/current_c\r\nfronius/meter/{serial}/frequency\r\nfronius/meter/{serial}/energy_exported\r\nfronius/meter/{serial}/energy_imported\r\n```\r\n\r\n## InfluxDB Measurements\r\n\r\n### fronius_inverter\r\n| Field | Type | Description |\r\n|-------|------|-------------|\r\n| ac_power | float | AC power output (W) |\r\n| dc_power | float | DC power input (W) |\r\n| ac_voltage_an/bn/cn | float | Phase voltages (V) |\r\n| ac_current | float | AC current (A) |\r\n| ac_frequency | float | Grid frequency (Hz) |\r\n| lifetime_energy | float | Total energy produced (Wh) |\r\n| status_code | int | Operating status code |\r\n\r\n### fronius_meter\r\n| Field | Type | Description |\r\n|-------|------|-------------|\r\n| power_total | float | Total power (W) |\r\n| power_a/b/c | float | Per-phase power (W) |\r\n| voltage_an/bn/cn | float | Phase voltages (V) |\r\n| current_a/b/c | float | Per-phase current (A) |\r\n| frequency | float | Grid frequency (Hz) |\r\n| energy_exported | float | Energy exported (Wh) |\r\n| energy_imported | float | Energy imported (Wh) |\r\n\r\n## Project Structure\r\n\r\n```\r\nfronius-modbus-mqtt/\r\n├── fronius_modbus_mqtt.py      # Main entry point\r\n├── fronius/                    # Python package\r\n│   ├── config.py               # YAML configuration loader\r\n│   ├── modbus_client.py        # Modbus TCP client with autodiscovery\r\n│   ├── register_parser.py      # SunSpec register parsing\r\n│   ├── mqtt_publisher.py       # MQTT publishing with change detection\r\n│   ├── influxdb_publisher.py   # InfluxDB writer with batching\r\n│   ├── device_cache.py         # Persistent device cache\r\n│   └── logging_setup.py        # Logging configuration\r\n├── config/\r\n│   ├── fronius_modbus_mqtt.example.yaml  # Example configuration\r\n│   ├── registers.json          # Modbus register definitions\r\n│   └── FroniusEventFlags.json  # Event flag mappings\r\n├── Dockerfile\r\n├── docker-compose.yml\r\n└── requirements.txt\r\n```\r\n\r\n## SunSpec Models\r\n\r\n| Model | Description |\r\n|-------|-------------|\r\n| 1 | Common Block (Manufacturer, Model, Serial) |\r\n| 101-103 | Inverter (Single/Split/Three Phase) |\r\n| 123 | Immediate Controls |\r\n| 160 | MPPT (Multiple Power Point Tracker) |\r\n| 201-204 | Meter (Single/Split/Three Phase) |\r\n\r\n## Supported Devices\r\n\r\nTested with:\r\n- Fronius Symo 17.5-3-M\r\n- Fronius Symo Advanced 17.5-3-M\r\n- Fronius Symo Advanced 20.0-3-M\r\n- Fronius Smart Meter TS 5kA-3\r\n\r\nShould work with any Fronius inverter with Modbus TCP enabled via DataManager.\r\n\r\n## Troubleshooting\r\n\r\n### Connection Issues\r\n- Verify Modbus TCP is enabled on the Fronius DataManager\r\n- Check firewall allows port 502\r\n- Ensure correct IP address in configuration\r\n\r\n### No Data\r\n- Check inverter Modbus IDs (typically 1-4)\r\n- Verify meter ID (typically 240)\r\n- Review logs for error messages\r\n\r\n### InfluxDB Errors\r\n- Verify bucket exists\r\n- Check API token has write permissions\r\n- Confirm organization name is correct\r\n\r\n## Manual Installation (without Docker)\r\n\r\n```bash\r\n# Create virtual environment\r\npython3 -m venv venv\r\nsource venv/bin/activate\r\n\r\n# Install dependencies\r\npip install -r requirements.txt\r\n\r\n# Copy and edit configuration\r\ncp config/fronius_modbus_mqtt.example.yaml config/fronius_modbus_mqtt.yaml\r\nnano config/fronius_modbus_mqtt.yaml\r\n\r\n# Run\r\npython fronius_modbus_mqtt.py\r\n\r\n# Run for inverters only\r\npython fronius_modbus_mqtt.py -d inverter\r\n\r\n# Run for meter only\r\npython fronius_modbus_mqtt.py -d meter\r\n```\r\n\r\n## Integration with docker-setup\r\n\r\nThis project integrates seamlessly with [docker-setup](https://github.com/sm26449/docker-setup):\r\n\r\n```bash\r\n# Install using docker-setup\r\ncd /opt/docker-setup\r\nsudo ./install.sh\r\n# Select: Add Services -\u003e fronius (or fronius:inverters, fronius:meter)\r\n```\r\n\r\n**Available variants:**\r\n- `fronius` - All devices (inverters + meter)\r\n- `fronius:inverters` - Inverters only\r\n- `fronius:meter` - Smart meter only\r\n\r\n## Contributing\r\n\r\nFound a bug or have a feature request? Please open an issue on [GitHub Issues](https://github.com/sm26449/fronius-modbus-mqtt/issues).\r\n\r\n## Author\r\n\r\n**Stefan M** - [sm26449@diysolar.ro](mailto:sm26449@diysolar.ro)\r\n\r\n## License\r\n\r\nMIT License - Free and open source software.\r\n\r\nCopyright (c) 2024 Stefan M \u003csm26449@diysolar.ro\u003e\r\n\r\nPermission is hereby granted, free of charge, to any person obtaining a copy\r\nof this software and associated documentation files (the \"Software\"), to deal\r\nin the Software without restriction, including without limitation the rights\r\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\ncopies of the Software, and to permit persons to whom the Software is\r\nfurnished to do so, subject to the following conditions:\r\n\r\nThe above copyright notice and this permission notice shall be included in all\r\ncopies or substantial portions of the Software.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r\nSOFTWARE.\r\n\r\n---\r\n\r\n**Disclaimer**: This software is provided \"as is\", without warranty of any kind. Use at your own risk when monitoring critical energy systems.\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsm26449%2Ffronius-modbus-mqtt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsm26449%2Ffronius-modbus-mqtt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsm26449%2Ffronius-modbus-mqtt/lists"}