Skip to content

solectrus/ha-integration

Repository files navigation

SOLECTRUS Home Assistant Integration

Note: This integration is in an early stage of development. Please report any issues you encounter.

This custom integration forwards Home Assistant entity values into an InfluxDB bucket used by your SOLECTRUS instance. It is tailored for the SOLECTRUS sensor keys so you can map each one to a Home Assistant entity, optionally overriding measurement and field names.

Features

  • Configure InfluxDB URL, token, organisation, and bucket directly in the config flow.
  • Map every SOLECTRUS sensor to a Home Assistant entity via the options flow; measurement/field defaults are pre-filled but can be overridden.
  • Writes are batched and sent every 5 seconds; points are deduplicated by (sensor, timestamp) (value may repeat).
  • When a sensor stayed at 0 for a longer time and then resumes with a positive value, the integration inserts an extra 0 point 1 second before the resume to avoid interpolation ramps.

Requirements

  • Home Assistant 2024.6 or newer
  • InfluxDB 2.x reachable from Home Assistant (URL + org + bucket + token)
  • An InfluxDB token with read and write access to the target bucket (read is used to detect existing field types so the integration matches them automatically)

Installation

HACS

  1. HACS → IntegrationsCustom repositories
  2. Add https://github.com/solectrus/ha-integration as type Integration
  3. Install SOLECTRUS
  4. Restart Home Assistant

Manual

  1. Copy custom_components/solectrus into your Home Assistant config/custom_components/ folder
  2. Restart Home Assistant

Setup (in Home Assistant)

  1. Ensure the integration is installed (see Installation above).
  2. Go to Settings → Devices & services → Add integration and search for SOLECTRUS.
  3. Enter your InfluxDB connection details (URL, token, org, bucket). The integration validates access by writing a test point.
  4. Open the integration Options and map the SOLECTRUS sensor keys to the Home Assistant entities you want to forward.

Notes:

  • This integration does not create entities; it exports values of existing entities you select in the options flow.
  • If you don't configure any mappings, no data will be written.

Data type detection

The integration determines the InfluxDB field type for each (measurement, field) pair automatically on startup:

  1. If the bucket already contains data for the field, the existing type wins (Influx freezes the field type on first write, so we have to match it).
  2. Otherwise, a curated default per sensor is used (int for power, float for SOC/temperatures, bool for connection states, string for status).

If the incoming Home Assistant state cannot be converted to the resolved type, it is skipped.

Advanced options

In the options flow you can enable Advanced options. This shows additional fields per sensor:

  • Measurement: override the default measurement name.
  • Field: override the default field name.

Once configured, the integration listens for entity state changes and writes them to InfluxDB following the above rules.

Development

scripts/setup    # Install/update dependencies into .venv
scripts/test     # Run the test suite (supports pytest args, e.g. scripts/test -v)
scripts/lint     # Format and lint the codebase with ruff
scripts/develop  # Start Home Assistant with the integration loaded

Troubleshooting

  • Setup error "Bucket not found": ensure the bucket exists and the token has write access to it.
  • TLS/certificate errors: https:// connections verify certificates; use a valid cert/CA, use http:// for local non-TLS InfluxDB, or disable Verify SSL certificate (insecure).
  • field type conflict in InfluxDB: this should no longer happen, since the integration auto-detects the existing field type from InfluxDB on startup. If it does, check that the configured token has read access to the bucket — without read, the integration cannot inspect the schema and falls back to its built-in defaults, which may not match.

About

Write data from Home Assistant to SOLECTRUS

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Sponsor this project

  •  

Contributors