Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/martinpham/homebridge-api
Homebridge GraphQL API, with characteristic subscriptions
https://github.com/martinpham/homebridge-api
Last synced: 19 days ago
JSON representation
Homebridge GraphQL API, with characteristic subscriptions
- Host: GitHub
- URL: https://github.com/martinpham/homebridge-api
- Owner: MartinPham
- Created: 2020-02-11T23:41:53.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2022-12-12T01:44:21.000Z (about 2 years ago)
- Last Synced: 2024-11-13T11:53:16.411Z (about 1 month ago)
- Language: JavaScript
- Size: 228 KB
- Stars: 16
- Watchers: 4
- Forks: 6
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Homebridge API (GraphQL based)
### WTF?
I was trying to build integrations between Homebridge and Alexa, but I couldn't find anything about Homebridge API, to get accessories & listen to statuses change. So I decided to build my own.
Homebridge API is based on GraphQL spec, currently it supports:
- Getting accessories & services & characteristics
- Querying characteristic's value
- Subscribing to characteristic's value change in realtime
- (Incoming) Setting characteristic's value### Installation
- Start Homebridge in Insecure mode ***(Important)***
- Install the plugin```
npm i -g homebridge-api
```- Add config
Check [sample-config.json](./sample-config.json) file```
{
"bridge": {
...
},
"api": {
"port": 18110,
"token": "TOP-SECRET-LOL",
"introspection": true,
"playground": true
}
}
```Where:
1. `port` GraphQL server port
2. `token` Token to access the GraphQL
3. `introspection` Enable GraphQL introspection (should disable it for public)
4. `playground` Enable GraphQL playground (should disable it for public)- Restart Homebridge
### Play time
**Don't forget to set header**
```
Authorization: YOUR-ACCESS-TOKEN-HERE
```- Query accessories
```
accessories {
aid
services {
type
characteristics {
iid
type
value
}
}
}
```
- Query characteristic```
query {
characteristic(aid: "21", iid: "10")
{
value
}
}
```- Subscribe to characteristic's value
```
subscription {
characteristicChanged(aid: "21", iid: "10")
{
value
}
}
```---
### TODO
- [ ] Mutation for updating characteristic
- [ ] Refactor
- [ ] Classic REST API