This is the forum archive of Homey. For more information about Homey, visit the Official Homey website.
The Homey Community has been moved to https://community.athom.com.
This forum is now read-only for archive purposes.
The Homey Community has been moved to https://community.athom.com.
This forum is now read-only for archive purposes.
[Advanced] Link HA Bridge to Homey
Sometimes 3rd part devices, apps or services don't provide a way to control stuff trough a http request, or just fail to give the ability to add a body and/or headers. If you ever looked at Homey it's API you see you do need the body to turn on lights etc. including the headers to authorize with the bearer token.
HA Bridge is a middle-ware that makes it possible to add Homey devices (or any other HTTP request) and anounce them to the network as Philips Hue bridge that has Lux lights. This way i control the lights directly from my Harmony remote and Alexa as home automation skill. But would work with any other 3rd party service that can connect to Hue.
HA Bridge even has the possibility to group multiple devices as one Hue light, or control a mediaplayer like Kodi. (e.g. "Alexa, turn on RTL 4")
In short a small tutorial on how to get it working:
- Follow the instructions on https://github.com/bwssytems/ha-bridge to install
- After installation and everything is running, go to the ip adress+port of your installation.
- Add a device
- The device name is the one used in Hue but also for the speech in Alexa!
- Near the bottom on the page you see 3 rows. ON, OFF and DIM.
- In the ON row select the device type as HTTP Device
- The target should be http://yourhomeyip/api/manager/devices/device/thedeviceidhere/state
- HTTP type should be set to PUT
- HTTP Body should be set as {"onoff": true} for ON, {"onoff": false} for OFF and {"dim": ${intensity.decimal_percent}} for DIM
- HTTP Header should be set as [{"name":"Authorization","value":"bearer YOURBEARERTOKENHERE"}]
- Set the content type to Aplication/JSON
- Now add the device and test it on the dashboard (there is an on, off and dim button there)
- If it works, you can let Alexa or any other service that connects to Hue scan for devices again and it should pop-up.
- You can copy devices and just change the device id, by adding multiple rows to the ON, OFF and DIM fields you can add more devices to one virtual Hue light.
In the end, i added my Kodi live tv channels as devices to HA bridge. This way i can say "Alexa, turn on RTL 4" so it switches to the right channel using the Kodi JSON api. My logitech harmony remote now has the ability as well to control some homey lights.
There even is a way to filter out what Echo can access what device, so if you would create a device named all lights in HA bridge. And filter each on, off and dim for each Echo Dot. It kind off knows in what room you are and switches the lights there.
EDIT:
To find the right device id you have 2 options:
1. Go to the devices page on homey from a chrome browser, right click the device card and chose inspect, there you should find a parameter called "data-id", this is the device id.
2. Go to http://yourhomeyip/api/manager/devices/device , this outputs all your devices. To make it read-able you can copy and past it in json lint for example. http://jsonlint.com/
TIP!
Replace the device id in the Target Item (within the ON, OFF and DIM part) with this variable ${device.targetDevice}
Then paste the device id in the main target field, this makes copying devices easier since you only need to change the name and the target.
HA Bridge is a middle-ware that makes it possible to add Homey devices (or any other HTTP request) and anounce them to the network as Philips Hue bridge that has Lux lights. This way i control the lights directly from my Harmony remote and Alexa as home automation skill. But would work with any other 3rd party service that can connect to Hue.
HA Bridge even has the possibility to group multiple devices as one Hue light, or control a mediaplayer like Kodi. (e.g. "Alexa, turn on RTL 4")
In short a small tutorial on how to get it working:
- Follow the instructions on https://github.com/bwssytems/ha-bridge to install
- After installation and everything is running, go to the ip adress+port of your installation.
- Add a device
- The device name is the one used in Hue but also for the speech in Alexa!
- Near the bottom on the page you see 3 rows. ON, OFF and DIM.
- In the ON row select the device type as HTTP Device
- The target should be http://yourhomeyip/api/manager/devices/device/thedeviceidhere/state
- HTTP type should be set to PUT
- HTTP Body should be set as {"onoff": true} for ON, {"onoff": false} for OFF and {"dim": ${intensity.decimal_percent}} for DIM
- HTTP Header should be set as [{"name":"Authorization","value":"bearer YOURBEARERTOKENHERE"}]
- Set the content type to Aplication/JSON
- Now add the device and test it on the dashboard (there is an on, off and dim button there)
- If it works, you can let Alexa or any other service that connects to Hue scan for devices again and it should pop-up.
- You can copy devices and just change the device id, by adding multiple rows to the ON, OFF and DIM fields you can add more devices to one virtual Hue light.
In the end, i added my Kodi live tv channels as devices to HA bridge. This way i can say "Alexa, turn on RTL 4" so it switches to the right channel using the Kodi JSON api. My logitech harmony remote now has the ability as well to control some homey lights.
There even is a way to filter out what Echo can access what device, so if you would create a device named all lights in HA bridge. And filter each on, off and dim for each Echo Dot. It kind off knows in what room you are and switches the lights there.
EDIT:
To find the right device id you have 2 options:
1. Go to the devices page on homey from a chrome browser, right click the device card and chose inspect, there you should find a parameter called "data-id", this is the device id.
2. Go to http://yourhomeyip/api/manager/devices/device , this outputs all your devices. To make it read-able you can copy and past it in json lint for example. http://jsonlint.com/
TIP!
Replace the device id in the Target Item (within the ON, OFF and DIM part) with this variable ${device.targetDevice}
Then paste the device id in the main target field, this makes copying devices easier since you only need to change the name and the target.
Comments
- where do you find the device id?
- can you screenshot the settings in HA bridge?
(of course remove any personal info)
going to slowely try this
best
eric
I still have a hard time getting HAbridge to work with homey via above settings.
this is what i now have, but still no reaction when testing from the lamp... i think im doing the HTTP header part wrong
But I get a:
Error on calling url to change device state: http://192.168.0.16/api/manager/devices/device/da97af26-ed09-4f95-9bdf-4fba69b917a6/state
I think its the ON/OFF state that is the challenge as the roller shutter 2 (FGRM-222) doesnt have an on/off but an up/down (which i tried instead already)
I am not sure yet how the blinds capability/class is working, can look into it tho.. (if i don't forget)
But something in the body should be changed from onoff to something else
You could PM me on Slack, might be easier tho..
this seems to be the solution from having HAbridge to work with Fibaro Roller Shutter 2 FGRM-222:
update the http body code to -> {"windowcoverings_state": "down"} (and up)
I recently got an Echo Dot, and I disliked the 'Alexa, ask Homey to...'. Now I can change on/off the lights, set the volume of the receiver (Alexa, set receiver to 20%), and more.
Tip: You can also combine Alexa's IFTTT integration with Homey for more scene-like things ("Alexa, trigger party mode").
I assume there is no way for more 'freedom' with trigger words in Alexa? I'm hoping for an "Alexa, play next song", which triggers a flow on Homey to go to the next Spotify song. I'm quite sure it doesn't exist rhough.
I'm not sure i would even use IFTTT for this example.
I would create a bitflip/virtual trigger in Homey, than via HAbridge connect that to Alexa. That bitflip would trigger whatever flow you'd like
ps. I would welcome more trigger words (or pre-set phrases/trigger words) for alexa as well.
(for example for my window screens i have HAbridge with Homey and Alexa and 'alexa turn screens on' just doesnt feel 100% correct should be something like 'alexa please turn screens up / down')
Any idea what could be wrong.
Happy to share any syslog or screenshots if helpful.
Haven't used it that much to debug tho (it's not that i created HA-Bridge :P )
you double checked their docs to see if you did all the right steps?
Can you comment on how you got the "Alexa, turn on RTL 4" working?
(i have some idea's but to re-invent the wheel...etc.)
Not at home now, but used the Kodi api for it since i am using Kodi for live tv
It does work with other devices that support hubs - although in those I am manually adding it by IP. I don't think you can do that for the Hue app in Homey.
For example, you can't get HA bridge to work with Google Home since that one relies on the web account API, where HA-bridge only works local.
Can't tell if this is the case with Homey as well tho...
I too read about Google using the Hue cloud service API but was hoping HA Bridge would be OK with Homey , which would allow me to integrate a load more devices.
K
I notice frequently that I need to ask alexa via HAbridge to activate/deactivate a plug (or bluetooth device) twice before it actually works, anyone any idea what that might be about?
I wish that Homey could implement this natively however... it seems many other companies have managed such (even down to Chinese companies like itead and their Sonoff controllers) so it doesnt seem like it should be a massive task for Homey to add Flows and Devices as Turn On commands. Distinguishing between Turn On / Turn Off commands would be difficult, but would imagine MVP of solely Turn On would be fine (that's the case with Yonomi for example)
I have a few quick questions I'm hoping you can help with...
- is there any way to adjust the % dim levels? I have a weird bug with my lightwave switch which if I ask for 100% then it does nothing, but if I ask for 95% then it is essentially goes to 100%. So if I could set 100% as 95% then that would mean the command could be what I'm used to
- I ran this by just running the .jar in windows and opening localhost in my browser - do I need to leave that browser window open? (I am right now) Is it enough just to set a shortcut to run the jar at windows startup to resume with same settings?
- do you have a basic guide on setting up the Harmony Hub for use with this? Reading the github it seems it needs a plugin, but can I just use the device ID from Homey and do it that way? I'm assuming that I can't break things with this but equally I don't want to play too much until I'm sure
- less urgent... is there any way to alter the response Alexa gives? "Ok" is fine, but I'm sure I read somewhere that you can overide this using this tool but I'm damned if I can find it now - feel like i imagined it!
Thank you once again - fab tutorial and very much looking forward to setting my own Alexa commands!!
I've tried both {"dim": ${intensity.decimal_percent-1}} and {"dim": ${--intensity.decimal_percent}} neither seemed to work
You tried {"dim": ${intensity.decimal_percent}-0.05} ? Where that is minus 5%.
Can't help you with the windows jar part, running it in a docker. Maybe there is a way in windows to start a .jar and keep it hidden? Something like this https://stackoverflow.com/questions/1617458/how-to-create-windows-service-from-java-jar ?
I am using the Harmony tab within the UI, but just to turn on/off the device. Not sure if this came with the docker or is default for ha-bridge.
No, "ok" is the basic alexa response as far as i know.
Hope this helps
When you say Harmony tab in UI you mean Homey or HA? The main thing I want is the favourite channels, since Homey doesn't do that and to use Alexa with them requires the Ask Harmony prefix
But there is a logitech harmony tab in ha-bridge here..
But i guess you could use homey for this...just make a virtual device (on off switch will do) add that to ha-bridge.
Then create a flow when the virtual device is turned on, switch to the channel (using the harmony app, IR or whatever)
When you named the device RTL 4 in ha-bridge, you can say "Alexa, turn on RTL 4".
I don't have a harmony tab in HA Bridge tho I do see a place to put in the IP address so maybe I'll try that tomorrow and see if it appears!
So...
Firstly, {"dim": ${intensity.decimal_percent}-0.05} didn't work sadly... I'm a bit stumped now but gonna have to leave it till the wife is out as she's getting fed up of me asking the light to turn to different percentages!!
However managed to get the Harmony tab added, and it pulled in the devices etc fine from my hub.
However, after following the button to get the activity set up, I have a Device in Alexa but it doesnt work... the test doesnt work either so there is obviously something wrong with my config.
Wondered if you'd mind comparing with yours?
Do any of the other fields need filling out here? (it autopopulated the rest)
Also, havent yet found a way to do favorite channels, but I'll settle for On/Off for now!!
I am having issue with favorite channels tho - not with the HA Bridge, but with Alexa.
I set up BBC One, but when I ask Alexa to turn on BBC One it sometimes works, but more often than not it says "I dont see any video skills set up yadda yadda" Not sure how to work around that as you don't want to name a channel something else just to avoid Alexa's issues
New question: anyone know a way to launch a flow with this?! I've tried viewing a device id for the flow in my browser but figure given the URL is set up for device, it's likely gonna fail anyway... Launching a device is great, but I'd love to be able to use it to turn on my house alarm (for example)
Edit - nevermind, i've just worked it out. For anyone else who might be interested
- turns out BetterLogic allows you to add a device - add a Bitfilp (after setting up a boolean in the settings)
- trigger your flow on variable change for that boolean
- job done