8000 Initial commit · homebridge/homebridge-examples@60f1a21 · GitHub
[go: up one dir, main page]

Skip to content

Commit 60f1a21

Browse files
committed
Initial commit
0 parents  commit 60f1a21

33 files changed

+5176
-0
lines changed

README.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# homebridge-examples
2+
3+
This repo bundles some example implementations for homebridge plugins. They provide some example code to get
4+
started with. They are also published on npm like regular plugins, so you can easily run them in your local
5+
homebridge instance. Refer to the respective `package.json` for the plugin name and install them as usual.
6+
7+
The examples are all written in Typescript and thus require at least homebridge `v1.0.0`.
8+
To build a plugin run the following commands in the respective plugin directory.
9+
10+
Run this command once to install all dependencies required by the plugin:
11+
```
12+
npm install
13+
```
14+
15+
After that run the following command to compile the Typescript files into Javascript
16+
(repeat this step every time you change something in the code).
17+
```
18+
npm run build
19+
```
20+
21+
If you need inspiration for a plugin written in Javascript you can just run the above commands and look at the
22+
generated Javascript code located in the `./dist` folder. You may need to ignore some code at the beginning of the file
23+
generated by the Typescript compiler.
24+
25+
## Examples for different homebridge plugin types
26+
27+
#### Accessory Plugins
28+
29+
Accessory plugins are the most basic and simplest plugins for homebridge. They should be used if you only want to
30+
expose a single accessory and don't require any special functionality.
31+
32+
* [Accessory Plugin](./accessory-example-typescript): A simple Switch accessory.
33+
34+
#### Platform Plugins:
35+
36+
Platform plugins are able to expose multiple accessories. Additionally, they are required if you want to use the
37+
Controller API.
38+
39+
* [Static Platform Plugin](./static-platform-example-typescript): Static platforms know which accessories they want to
40+
expose on start up. The set of accessories cannot change over the lifespan of the plugin.
41+
* [Dynamic Platform Plugin](./dynamic-platform-example-typescript): Dynamic platforms can dynamically add or remove
42+
accessories at runtime. Accessories are fully stored to disk by homebridge, and the exact state is reconstructed on
43+
a reboot. The plugin can store additional context as well.
44+
* [Independent Platform Plugin](./independent-platform-example-typescript): Independent platforms are typically used
45+
when the platform intends to only expose external accessories or provides other functionality while not exposing
46+
an accessory at all.
47+
48+
## Other example plugins
49+
50+
* [Bridged Camera Platform](./bridged-camera-example-typescript)
Lines changed: 205 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,205 @@
1+
# Created by .ignore support plugin (hsz.mobi)
2+
### HAP-NodeJS files
3+
persist
4+
5+< 10000 /span>
### Node template
6+
# Logs
7+
logs
8+
*.log
9+
npm-debug.log*
10+
yarn-debug.log*
11+
yarn-error.log*
12+
lerna-debug.log*
13+
14+
# Diagnostic reports (https://nodejs.org/api/report.html)
15+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
16+
17+
# Runtime data
18+
pids
19+
*.pid
20+
*.seed
21+
*.pid.lock
22+
23+
# Directory for instrumented libs generated by jscoverage/JSCover
24+
lib-cov
25+
26+
# Coverage directory used by tools like istanbul
27+
coverage
28+
*.lcov
29+
30+
# nyc test coverage
31+
.nyc_output
32+
33+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
34+
.grunt
35+
36+
# Bower dependency directory (https://bower.io/)
37+
bower_components
38+
39+
# node-waf configuration
40+
.lock-wscript
41+
42+
# Compiled binary addons (https://nodejs.org/api/addons.html)
43+
build/Release
44+
45+
# Dependency directories
46+
node_modules/
47+
jspm_packages/
48+
49+
# Snowpack dependency directory (https://snowpack.dev/)
50+
web_modules/
51+
52+
# TypeScript cache
53+
*.tsbuildinfo
54+
55+
# Optional npm cache directory
56+
.npm
57+
58+
# Optional eslint cache
59+
.eslintcache
60+
61+
# Microbundle cache
62+
.rpt2_cache/
63+
.rts2_cache_cjs/
64+
.rts2_cache_es/
65+
.rts2_cache_umd/
66+
67+
# Optional REPL history
68+
.node_repl_history
69+
70+
# Output of 'npm pack'
71+
*.tgz
72+
73+
# Yarn Integrity file
74+
.yarn-integrity
75+
76+
# dotenv environment variables file
77+
.env
78+
.env.test
79+
80+
# parcel-bundler cache (https://parceljs.org/)
81+
.cache
82+
.parcel-cache
83+
84+
# Next.js build output
85+
.next
86+
87+
# Nuxt.js build / generate output
88+
.nuxt
89+
dist
90+
91+
# Gatsby files
92+
.cache/
93+
# Comment in the public line in if your project uses Gatsby and not Next.js
94+
# https://nextjs.org/blog/next-9-1#public-directory-support
95+
# public
96+
97+
# vuepress build output
98+
.vuepress/dist
99+
100+
# Serverless directories
101+
.serverless/
102+
103+
# FuseBox cache
104+
.fusebox/
105+
106+
# DynamoDB Local files
107+
.dynamodb/
108+
109+
# TernJS port file
110+
.tern-port
111+
112+
# Stores VSCode versions used for testing VSCode extensions
113+
.vscode-test
114+
115+
# yarn v2
116+
117+
.yarn/cache
118+
.yarn/unplugged
119+
.yarn/build-state.yml
120+
.pnp.*
121+
122+
### VisualStudioCode template
123+
.vscode/*
124+
!.vscode/settings.json
125+
!.vscode/tasks.json
126+
!.vscode/launch.json
127+
!.vscode/extensions.json
128+
*.code-workspace
129+
130+
# Local History for Visual Studio Code
131+
.history/
132+
133+
### JetBrains template
134+
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
135+
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
136+
137+
# User-specific stuff
138+
.idea/**/workspace.xml
139+
.idea/**/tasks.xml
140+
.idea/**/usage.statistics.xml
141+
.idea/**/dictionaries
142+
.idea/**/shelf
143+
144+
# Generated files
145+
.idea/**/contentModel.xml
146+
147+
# Sensitive or high-churn files
148+
.idea/**/dataSources/
149+
.idea/**/dataSources.ids
150+
.idea/**/dataSources.local.xml
151+
.idea/**/sqlDataSources.xml
152+
.idea/**/dynamic.xml
153+
.idea/**/uiDesigner.xml
154+
.idea/**/dbnavigator.xml
155+
156+
# Gradle
157+
.idea/**/gradle.xml
158+
.idea/**/libraries
159+
160+
# Gradle and Maven with auto-import
161+
# When using Gradle or Maven with auto-import, you should exclude module files,
162+
# since they will be recreated, and may cause churn. Uncomment if using
163+
# auto-import.
164+
# .idea/artifacts
165+
# .idea/compiler.xml
166+
# .idea/jarRepositories.xml
167+
# .idea/modules.xml
168+
# .idea/*.iml
169+
# .idea/modules
170+
# *.iml
171+
# *.ipr
172+
173+
# CMake
174+
cmake-build-*/
175+
176+
# Mongo Explorer plugin
177+
.idea/**/mongoSettings.xml
178+
179+
# File-based project format
180+
*.iws
181+
182+
# IntelliJ
183+
out/
184+
185+
# mpeltonen/sbt-idea plugin
186+
.idea_modules/
187+
188+
# JIRA plugin
189+
atlassian-ide-plugin.xml
190+
191+
# Cursive Clojure plugin
192+
.idea/replstate.xml
193+
194+
# Crashlytics plugin (for Android Studio and IntelliJ)
195+
com_crashlytics_export_strings.xml
196+
crashlytics.properties
197+
crashlytics-build.properties
198+
fabric.properties
199+
200+
# Editor-based Rest Client
201+
.idea/httpRequests
202+
203+
# Android studio 3.1+ serialized cache file
204+
.idea/caches/build_file_checksums.ser
205+

accessory-example-typescript/LICENSE

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
ISC License (ISC)
2+
Copyright (c) 2020 Andreas Bauer
3+
4+
Permission to use, copy, modify, and/or distribute this software for any
5+
purpose with or without fee is hereby granted, provided that the above
6+
copyright notice and this permission notice appear in all copies.
7+
8+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
9+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
10+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
11+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
12+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
13+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
14+
PERFORMANCE OF THIS SOFTWARE.

0 commit comments

Comments
 (0)
0