Description | Link |
---|---|
Build | |
Nuget | |
Nuget Prerelease |
This repo contains the source code for a C# Api for Athom's Homey. It does not yet cover the complete feature set. There is a java script api client available https://developer.athom.com/docs/api. The Rest Api can be guessed according to the documentation.
// Homey Login credentials
private const string UserName = "<USER_NAME>";
private const string Password = "<PASSWORD>";
// client id and client secret from: https://tools.developer.homey.app/api/projects
// cloud id from: https://tools.developer.homey.app/tools/system
private static HomeyApiConfig _apiConfig = new HomeyApiConfig
{
ClientId = "<CLIENT_ID>",
ClientSecret = "<CLIENT_SECRET>",
CloudId = "<CLOUD_ID>"
};
// You can check the local homey ip over the app with More/Settings/General/About
HomeyClient client = new HomeyClient
{
HomeyIp = HomeyIp
};
client.Authenticate(_apiConfig, UserName, Password)
See section below how to extract the bearer token manually
// You can check the local homey ip over the app with More/Settings/General/Abou
HomeyClient client = new HomeyClient
{
Token = BearerToken,
HomeyIp = HomeyIp
};
Implemented commands
- Get device for id
- Get all devices
- Get devices for zone id
- Get capability time log
- Gel all zones
- Get all flows
- Get flow for flow id
- Get all alarms
- Update alarm
- Get system info
- Set boolean capability
- Enable flow
- Trigger flow
IList<Device> devices = await client.GetDevices();
IList<Flow> flows = await client.GetFlows();
IList<Alarm> alarms = await client.GetAlarms();
...
During my reverse engineering I stumbled over the following blog post: https://homey.solweb.no/advanced-api-usage/bearertoken
The javascript code did not work out of the box for me so I did slight modifications in c# The authentication is done with six requests to the following endpoints
- https://accounts.athom.com/login
- https://accounts.athom.com/oauth2/authorise?
- https://accounts.athom.com/authorise?client_id=
- https://api.athom.com/oauth2/token
- https://api.athom.com/delegation/token?audience=homey
- https://' + cloudid + '.connect.athom.com/api/manager/users/login
Homey does not yet provide an access token, however you can obtain one with the following steps.
- Open https://developer.athom.com/
- Press Login
- Open the browser dev tools --> F12 and switch to the Network tab
- Log in with your Homey mail and password You should find a Get request "api/manager/sessions/session/me" which contains you local homey ip address if you are in the local network. Request URL: "https://LOCAL-HOMEY-IP.homey.homeylocal.com/api/manager/sessions/session/me" There you should fine something like the following under Request Header "authorization: Bearer 888999-19fe-4fa0-9999-b32982499999:9c1a21da-1df4-9999-8594-46fd7e799999:c6d7b6096df10a5fd2d8888888ff447ff1ca0e9c"
- Use the whole token after Beaer in that case it would be "888999-19fe-4fa0-9999-b32982499999:9c1a21da-1df4-9999-8594-46fd7e799999:c6d7b6096df10a5fd2d8888888ff447ff1ca0e9c"