DiversIT Europe
Previous Home Jan 17, 2021 Netatmo integration in Home Assistant via MQTT Tags: homeassistant iot mqtt netatmo

Instead of using the default Netatmo integration in Home Assistant, I switch to using an MQTT bridge. I found a nice project and extended it so data entries now automatically get discovered via Home Assistant’s MQTT Auto Discovery.

Netatmo integration

In the new Home Assistant setup, I then started to add all current integration, like Netatmo. However, it seemed to be missing Netatmo data like wifi_status, rf_status etc and also the integration did not seem to be very stable. Complaining about webhooks etc.

Since I was already planning to get more integration via MQTT, so the latest data values can be retained there so HA does not have to contact the external service every time it (re)starts, I decided to do the same for the Netatmo integration..

mqtt-netatmo-bridge

I quickly found this great mqtt-netatmo-bridge project from Terafin (many thanks!) which I extended to:

  • support .env file for environment variables, which is really useful during development
  • support multiple Netatmo devices/stations. This seemed to be a quick fix, so why not?
  • add support for Home Assistants MQTT Auto Discovery.
  • expose additional properties like wifi_status (for the weather station) and rf_status (for weather modules).

Home Assistant MQTT Discovery

Now, when enabling the HOME_ASSISTANT_AUTO_DISCOVERY feature, the bridge will publish configuration settings to a homeassistant/netatmo/... topic which get automatically picked up by Home Assistant MQTT Discovery. All data entries are grouped by Netatmo Module which is represented in HA as a device.

Check out the sources on github.
A docker image diversit/mqtt-netatmo-bridge is also available to quickly get started.

I use this setup in docker-compose:

  mqtt-netatmo-bridge:
    image: diversit/mqtt-netatmo-bridge:latest
    environment:
      - NETATMO_USER=<netatmo-account-user>
      - NETATMO_PASS=<netatmo-account-password>
      - NETATMO_CLIENT_ID=<netatmo-app-id>
      - NETATMO_CLIENT_SECRET=<netatmo-app-secret>
      - TOPIC_PREFIX=/netatmo
      - POLL_INTERVAL_SECONDS=300
      - RETAIN_VALUES=true
      - HOMEASSISTANT_AUTO_DISCOVERY=true
      - MQTT_HOST=mqtt://mqtt
      - MQTT_USER=<mqtt-user>
      - MQTT_PASS=<mqtt-pass>
      - MQTT_NAME=netatmo-bridge
      - MQTT_STATUS_TOPIC_PREFIX=/status/
      - LOG_LEVEL=info
      - LOGGING_NAME=mqtt-netatmo-bridge
      - TZ=Europe/Amsterdam

Note:

  • I use a poll interval of 5 minutes. I think the Netatmo device only reports to the Netatmo cloud every 10 minutes, so this is fast enough. No need to put more pressure on their API with the chance of getting banned due to rate limitting.
  • The MQTT_STATUS_TOPIC_PREFIX is needed to fix an issue with a dependency used by this project. Without this, or with a different prefix, the ‘up’ status is published to another topic as the ‘down’ status._