Homey.Net 1.3.1

dotnet add package Homey.Net --version 1.3.1
NuGet\Install-Package Homey.Net -Version 1.3.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Homey.Net" Version="1.3.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Homey.Net --version 1.3.1
#r "nuget: Homey.Net, 1.3.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Homey.Net as a Cake Addin
#addin nuget:?package=Homey.Net&version=1.3.1

// Install Homey.Net as a Cake Tool
#tool nuget:?package=Homey.Net&version=1.3.1

Homey-.Net

Description Link
Build Build Status
Nuget Nuget
Nuget Prerelease Nuget (with prereleases)

Intro

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.

Usage

Initialize with authentication

// 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)

Initialize with bearer token

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
};

Fetch Data

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();
...

Sample Application

Screenshot

Authentication

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

  1. https://accounts.athom.com/login
  2. https://accounts.athom.com/oauth2/authorise?
  3. https://accounts.athom.com/authorise?client_id=
  4. https://api.athom.com/oauth2/token
  5. https://api.athom.com/delegation/token?audience=homey
  6. https://' + cloudid + '.connect.athom.com/api/manager/users/login

Obtaining an Access Token manually

Homey does not yet provide an access token, however you can obtain one with the following steps.

  1. Open https://developer.athom.com/
  2. Press Login
  3. Open the browser dev tools --> F12 and switch to the Network tab
  4. 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"
  5. Use the whole token after Beaer in that case it would be "888999-19fe-4fa0-9999-b32982499999:9c1a21da-1df4-9999-8594-46fd7e799999:c6d7b6096df10a5fd2d8888888ff447ff1ca0e9c"
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.3.1 402 12/5/2021
1.3.1-beta0001 202 12/5/2021
1.3.0-beta0022 190 12/5/2021
1.3.0-beta0020 202 12/5/2021
1.2.2-beta0016 756 12/1/2021
1.2.1 495 12/5/2020
1.2.1-beta0006 324 12/5/2020
1.2.0 466 12/5/2020
1.2.0-beta0018 296 12/5/2020
1.2.0-beta0009 298 12/4/2020
1.0.0 413 12/4/2020

Updated vulnerable packages