Skip to content

Home Assistant Integration

aranet-service can publish sensor readings to MQTT and optionally register supported sensors with Home Assistant via MQTT discovery.

  • aranet-service running with MQTT enabled
  • A reachable MQTT broker such as Mosquitto or EMQX
  • Home Assistant with the MQTT integration configured
  1. Configure an MQTT broker.
  2. Enable MQTT in server.toml.
  3. Turn on mqtt.homeassistant = true.
  4. Add the MQTT integration in Home Assistant.
  5. Wait for aranet-service to publish its first readings and discovery payloads.

Edit ~/.config/aranet/server.toml:

[mqtt]
enabled = true
broker = "mqtt://localhost:1883"
topic_prefix = "aranet"
client_id = "aranet-service"
qos = 1
retain = true
homeassistant = true
ha_discovery_prefix = "homeassistant"
# Optional broker auth
# username = "aranet"
# password = "your-password"
[[devices]]
address = "Aranet4 XXXXX"
alias = "office"
poll_interval = 60

Key points:

  • topic_prefix controls the reading topics, such as aranet/office/co2.
  • ha_discovery_prefix controls the Home Assistant discovery topics, usually homeassistant.
  • homeassistant = true enables discovery publishing.

Add or configure the MQTT integration in Home Assistant:

mqtt:
broker: localhost
port: 1883
# username: aranet
# password: your-password

You can also add MQTT from the Home Assistant UI at Settings → Devices & Services → Add Integration → MQTT.

aranet-service publishes readings to these topics:

TopicDescription
{prefix}/{device}/jsonFull reading as JSON
{prefix}/{device}/co2CO₂ concentration
{prefix}/{device}/temperatureTemperature in °C
{prefix}/{device}/humidityRelative humidity
{prefix}/{device}/pressurePressure in hPa
{prefix}/{device}/batteryBattery percentage
{prefix}/{device}/statusStatus string: green, yellow, red, error
{prefix}/{device}/radonRadon value when available
{prefix}/{device}/radon_avg_24h24-hour radon average when available
{prefix}/{device}/radon_avg_7d7-day radon average when available
{prefix}/{device}/radon_avg_30d30-day radon average when available
{prefix}/{device}/radiation_rateRadiation rate when available
{prefix}/{device}/radiation_totalRadiation total when available

{device} is the configured alias when present, otherwise the device address, sanitized for MQTT topic safety.

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

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: measurement
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"
  1. Confirm the broker is reachable.
  2. Confirm Home Assistant is connected to the same broker.
  3. Check aranet-service logs for MQTT connection errors.
  4. Subscribe to both the reading topics and discovery topics:
Terminal window
mosquitto_sub -t 'aranet/#' -v
mosquitto_sub -t 'homeassistant/#' -v

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”
  1. Make sure mqtt.homeassistant = true.
  2. Make sure the service has at least one configured device.
  3. Wait for the service to publish readings after startup or config reload.
  4. Verify the discovery prefix matches Home Assistant expectations, usually homeassistant.