Home Assistant Integration
aranet-service can publish sensor readings to MQTT and optionally register supported sensors with Home Assistant via MQTT discovery.
Prerequisites
Section titled “Prerequisites”aranet-servicerunning with MQTT enabled- A reachable MQTT broker such as Mosquitto or EMQX
- Home Assistant with the MQTT integration configured
Quick Setup
Section titled “Quick Setup”- Configure an MQTT broker.
- Enable MQTT in
server.toml. - Turn on
mqtt.homeassistant = true. - Add the MQTT integration in Home Assistant.
- Wait for aranet-service to publish its first readings and discovery payloads.
aranet-service Configuration
Section titled “aranet-service Configuration”Edit ~/.config/aranet/server.toml:
[mqtt]enabled = truebroker = "mqtt://localhost:1883"topic_prefix = "aranet"client_id = "aranet-service"qos = 1retain = truehomeassistant = trueha_discovery_prefix = "homeassistant"
# Optional broker auth# username = "aranet"# password = "your-password"
[[devices]]address = "Aranet4 XXXXX"alias = "office"poll_interval = 60Key points:
topic_prefixcontrols the reading topics, such asaranet/office/co2.ha_discovery_prefixcontrols the Home Assistant discovery topics, usuallyhomeassistant.homeassistant = trueenables discovery publishing.
Home Assistant Setup
Section titled “Home Assistant Setup”Add or configure the MQTT integration in Home Assistant:
mqtt: broker: localhost port: 1883 # username: aranet # password: your-passwordYou can also add MQTT from the Home Assistant UI at Settings → Devices & Services → Add Integration → MQTT.
Published MQTT Topics
Section titled “Published MQTT Topics”aranet-service publishes readings to these topics:
| Topic | Description |
|---|---|
{prefix}/{device}/json | Full reading as JSON |
{prefix}/{device}/co2 | CO₂ concentration |
{prefix}/{device}/temperature | Temperature in °C |
{prefix}/{device}/humidity | Relative humidity |
{prefix}/{device}/pressure | Pressure in hPa |
{prefix}/{device}/battery | Battery percentage |
{prefix}/{device}/status | Status string: green, yellow, red, error |
{prefix}/{device}/radon | Radon value when available |
{prefix}/{device}/radon_avg_24h | 24-hour radon average when available |
{prefix}/{device}/radon_avg_7d | 7-day radon average when available |
{prefix}/{device}/radon_avg_30d | 30-day radon average when available |
{prefix}/{device}/radiation_rate | Radiation rate when available |
{prefix}/{device}/radiation_total | Radiation total when available |
{device} is the configured alias when present, otherwise the device address, sanitized for MQTT topic safety.
Auto-Discovery Behavior
Section titled “Auto-Discovery Behavior”With mqtt.homeassistant = true, aranet-service publishes Home Assistant discovery payloads for the core sensors it can classify from the configured device type:
- CO₂
- Temperature
- Humidity
- Pressure
- Battery
Manual Sensors
Section titled “Manual Sensors”If you want to expose radon or radiation topics manually, add MQTT sensors in configuration.yaml:
mqtt: sensor: - name: "Basement Radon" state_topic: "aranet/basement/radon" unit_of_measurement: "Bq/m³" state_class: measurement
- name: "Basement Radon 7d" state_topic: "aranet/basement/radon_avg_7d" unit_of_measurement: "Bq/m³" state_class: measurement
- name: "Radiation Rate" state_topic: "aranet/radiation/radiation_rate" unit_of_measurement: "µSv/h" state_class: measurementAutomation Example
Section titled “Automation Example”automation: - alias: "High CO2 Alert" trigger: - platform: numeric_state entity_id: sensor.office_co2 above: 1000 for: minutes: 5 action: - service: notify.mobile_app data: title: "High CO₂ Level" message: "Office CO₂ is {{ states('sensor.office_co2') }} ppm"Troubleshooting
Section titled “Troubleshooting”Entities do not appear
Section titled “Entities do not appear”- Confirm the broker is reachable.
- Confirm Home Assistant is connected to the same broker.
- Check aranet-service logs for MQTT connection errors.
- Subscribe to both the reading topics and discovery topics:
mosquitto_sub -t 'aranet/#' -vmosquitto_sub -t 'homeassistant/#' -vTopic names are unexpected
Section titled “Topic names are unexpected”Device aliases are preferred for topic names. MQTT topic segments are sanitized by replacing spaces, /, #, and + with _.
Discovery is enabled but no sensors appear
Section titled “Discovery is enabled but no sensors appear”- Make sure
mqtt.homeassistant = true. - Make sure the service has at least one configured device.
- Wait for the service to publish readings after startup or config reload.
- Verify the discovery prefix matches Home Assistant expectations, usually
homeassistant.