Configure Homebridge with Ansible

Homebridge is an open source implementation of Apple’s home automation protocol HomeKit. It helps you to connect non HomeKit compatible (smart home) devices with dozens of plugins. Privately, I use it with a few Osram Plugs, Sonos and to power devices via Wake On LAN. My nello one is connected aswell.

I’ve created a role for Ansible so that I don’t have to edit the JSON configuration file of Homebridge by hand anymore. You can find it on GitHub together with an example playbook.

- hosts: pi
  become: true

  roles:
    - role: geerlingguy.nodejs
      tags:
        - nodejs
    - role: homebridge
      tags:
        - homebridge

  vars:
    nodejs_npm_global_packages:
      - homebridge
      - homebridge-hue
      - homebridge-sonos
    npm_config_unsafe_perm: "true"
    homebridge_username: "CC:22:3D:AA:AA:AA"
    homebridge_port: 51826
    homebridge_pin: "030-45-153"

    homebridge_platforms:
      - platform: Hue
        lights: true
        host: hue.lan
        nupnp: false

    homebridge_accessories:
      - accessory: Sonos
        name: Sonos Kitchen
        room: Kitchen
        mute: false