Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for landscape transformer power on/off #29

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<span align="center">

# Homebridge Hubspace
# Homebridge Hubspace

<a href="https://www.npmjs.com/homebridge-hubspace">
<img src="https://img.shields.io/npm/v/homebridge-hubspace.svg?logo=npm&logoColor=fff&label=NPM+package&color=limegreen" alt="Hubspace for Homebridge on npm" />
Expand All @@ -17,12 +17,15 @@
</span>

# About plugin

Hubspace is a platform for range of devices sold at HomeDepot. This plugin tries to integrate as many of these devices so that you can control them from HomeKit.

# Disclaimer

I do not own any rights to Hubspace. Any work published here is solely for my own convenience. I am not making any guarantees about the code or products referenced here.

# Tested products

Below you can find a table of products that have been tested with this plugin. Some products share similarities among one another (e.g. lights), however, that does not guarantee that they will all work.

Not all features for all products are implemented. Please see the functions below of what is implemented. If you need a feature that is not implemented create an issue for it.
Expand All @@ -31,12 +34,18 @@ Not all features for all products are implemented. Please see the functions belo
| --- | --- |
| [Universal Smart Wi-Fi 4-Speed Ceiling Fan](https://www.homedepot.com/p/Hampton-Bay-Universal-Smart-Wi-Fi-4-Speed-Ceiling-Fan-White-Remote-Control-For-Use-Only-With-AC-Motor-Fans-Powered-by-Hubspace-76278/315169181?) | <ul><li>Light on/off</li><li>Fan on/off</li><li>Light brightness</li><li>Fan speed</li></ul> |
| [Defiant Smart Plug](https://www.homedepot.com/p/Defiant-15-Amp-120-Volt-Smart-Wi-Fi-Bluetooth-Plug-with-1-Outlet-Powered-by-Hubspace-HPPA11AWB/315636834) | <ul><li>Power on/off</li></ul> |
| [Smart 200 Watt Landscape Transformer](https://www.homedepot.com/p/Hampton-Bay-Smart-200-Watt-Landscape-Lighting-Transformer-with-Dusk-to-Dawn-Sensor-Powered-by-Hubspace-HB-200-1215WIFI/315058962) | <ul><li>Zone power on/off</li></ul>

# Development

There is no official documentation for Hubspace products. Under the hood they use Afero cloud as the mechanism that controls the products. Any functionality here is gained by experimenting with various functions of the devices. Afero provides simple explanation of [their APIs](https://developer.afero.io/API-DeviceEndpoints), however, this is in no way comprehensive.

If you find that a product does not work as intended, or you want to request a new product, please create a ticket for it in the issues section. You are always more than welcome to create a PR with any fixes or additions to the plugin.

## Local Testing

This repository uses Jest with ts-jest for testing. These tests are currently only set up for local validation. Some tests will be marked "skipped" using `xdescribe` or `xit` if they require access to real credentials. As convention, set `HUBSPACE_USERNAME` and `HUBSPACE_PASSWORD` environment variables, then remove the `x` from the `describe` or `it` blocks to run the live tests.

## Guidelines

Any code you submit must be readable, be properly commented where necessary, and follow some common sense code quality.
Expand All @@ -54,16 +63,20 @@ This is a TypeScript project, therefore, TypeScript naming conventions must be f
Any ESLint issues need to be resolved before code can be merged. To check for production build linter issues you can run `npm run prepublishOnly`.

## Adding new features

To add new features to the do the following:

1. Create an issue for the feature (unless there is an issue already)
1. Assign the issue to yourself
1. Create a new branch for the issue and name is as _{issue number}-{issue description}_ (e.g. 6-add-laser-support)
1. Once ready issue a PR that is linked to the issue

## Development authentication

Hubspace platform uses [Keycloak](https://www.keycloak.org) for authentication. To develop new features you will need to request JWT from Keycloak to authenticate your requests against the platform.

To get the token send HTTP request with `x-www-form-urlencoded` body to the URL below.

```
POST https://accounts.hubspaceconnect.com/auth/realms/thd/protocol/openid-connect/token
```
Expand All @@ -77,4 +90,4 @@ Your payload should include the following fields.
| username | YOUR_USERNAME |
| password | YOUR_PASSWORD |

Once you receive the token you can make request to Afero with it to investigate the devices and commands.
Once you receive the token you can make request to Afero with it to investigate the devices and commands.
5 changes: 5 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
};
Loading