Per request, here is what I learned about HA Bridge to get it working.
I downloaded the jar and installed Java on my Debian server following the instruction on their main github page. The docker image didn’t start successfully and I eventually gave up trying to figure out why.
Next I configured MQTT on the Bridge Control tab with my IP and port of MQTT. Most of my lights are connected to HA via MQTT so I figured that would be the fastest way to get the lights to respond since HA would just be another hop before HA sent the MQTT message. Also, the Home Assistant integration in HA Bridge always throws a null exception after configuring the IP and port. I opened an issue for that and again have abandoned that for now.
To configure a light I added them as follows:
Name =
Device Type = switch
Map Type = MQTT
On Items: Type = MQTT Message. Target Item =
Off Items: same as On Items but changed payload from ON to OFF
Dim Items: only add if switch is dimable, and used the “intensity.percent” in the payload, for example:
{"clientId":"ha-bridge","topic":"smartthings/Lamp One/level/cmd","message":"${intensity.percent}","qos":"1","retain":"false"}
An example MQTT JSON to turn one of my devices on:
{"clientId":"ha-bridge","topic":"cmnd/GarageLight/POWER","message":"ON","qos":"1","retain":"false"}
I also have several HA scripts that control my Home Theater, stereo receiver, TV, and Shield. To run those via Alexa I call a bash script from HA-Bridge which sends the request to HA (since HA integration is not functional for now). For example,
On Items: Type = Execute Command Target Item = ha-run-script home_theater_on
The bash script looks like this:
#!/bin/bash
# Usage: ha-run-script {script}
curl --silent -X POST \
-H "Authorization: Bearer <insert a long-lived token here> " \
-H "Content-Type: application/json" \
-d "{\"entity_id\": \"script.${1}\" }" \
http://<insert HA IP here>:8123/api/services/script/turn_on
I am also migrating to a more generic bash script called ha-run-service that can run ANY HA service and not just start a script:
#!/bin/bash
if (( $# != 3 )); then
echo Usage: ha-run-service {domain} {service} {entity}
exit 1
fi
curl --silent --request POST \
--header "Authorization: Bearer <insert a long-lived token here> " \
--header "Content-Type: application/json" \
--data "{\"entity_id\": \"${3}\" }" \
http://<insert HA IP here>:8123/api/services/${1}/${2} >>/dev/null
I set the walled garden config per the doc to limit what scripts HA-Bridge can run and from what directory (recommended).