Sign inSign up

tomoinn/bifrost

By tomoinn

•Updated almost 3 years ago

Bridge between Hue and Pixelblaze devices

Image
0

568

tomoinn/bifrost repository overview

Source at https://github.com/tomoinn/bifrost⁠

Receives events generated by the patrickstigler/hue-mqtt-bridge-rpi (https://hub.docker.com/r/patrickstigler/hue-mqtt-bridge-rpi⁠) Hue to MQTT bridge, and uses them to control movement through a Pixelblaze (https://electromage.com/pixelblaze⁠) playlist. The top button (I) on the switch either turns the lights on or switches to the next item in the playlist, the bottom button (O) turns them off, and the brightness buttons behave as you'd expect. I'm running this on a Pi4 using the following docker-compose.yml, this sets up an MQTT server and the Hue to MQTT bridge, then runs my code off the same MQTT server.

---
version: "2.2"
services:
  mosquitto:
    image: eclipse-mosquitto:openssl
    container_name: mosquitto
    user: 1000:1000
    volumes:
      - /home/pi/mqtt/mosquitto:/mosquitto/:rw
    ports:
      - 1883:1883
      - 9001:9001
    restart: unless-stopped
  hue-mqtt-bridge:
    image: patrickstigler/hue-mqtt-bridge-rpi
    container_name: hue-mqtt-bridge
    volumes:
      - /home/pi/mqtt/hue-mqtt-bridge/:/home/pi/node/config
    depends_on: 
      - mosquitto
    restart: unless-stopped
  bifrost:
    network-mode: host
    image: tomoinn/bifrost
    container_name: bifrost
    volumes:
      - /home/pi/mqtt/bifrost:/config/:rw
    depends_on:
      - mosquitto
      - hue-mqtt-bridge
    restart: unless-stopped

IMPORTANT - network-mode: host is needed, I think because pixelblaze discovery uses multicast. There might be a better way to manage this but honestly I don't know enough about docker to know what that might be.

To configure the relationship between switches and pixelblaze controllers, and to set up the MQTT parameters, you need a bifrost.yml file mounted to /config/ in the image, a redacted version is as follows:

mappings:
  - hue: kitchen_led_control
    pb: kitchen
    default_brightness: 1
  - hue: drinks_led_control
    pb: drinks
    default_brightness: 1
mqtt:
  host: [MQTT_HOST]
  port: [MQTT_PORT]
  user: [USER_NAME]
  password: [MQTT_PASSWORD]

The mappings use the name of the event from the hue bridge and the name of the pixelblaze. If you run this without detaching and press your desired hue switch's buttons you should see the name you need in the logs from bifrost. The pixelblaze name is whatever you've set in your pixelblaze web UI. Default brightness is the intensity that the pixelblaze will be set to when pressing the (I) button when the current intensity is zero, and should range between 0 and 1.0.

As an alternative, you can send MQTT events directly to control Bifrost, the events should have a key of bifrost/SWITCH_NAME/[ON|UP|DOWN|OFF] with no payload specified to simulate the effect of pressing those buttons on a physical switch. I added this as I've now moved my own setup away from Hue and entirely in Home Assistant with the Hue dimmers attached over ZHA. If you're using a similar configuration you can find a blueprint to add the necessary link between the switch, MQTT, and the pixelblaze at https://community.home-assistant.io/t/control-pixelblaze-with-zha-hue-dimmer-switches/663768⁠

Tag summary

Content type

Image

Digest

sha256:60ab69a25…

Size

66.4 MB

Last updated

almost 3 years ago

docker pull tomoinn/bifrost