You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A plugin's custom user interface has two main components:
31
38
32
39
*[User Interface](#user-interface-api) - this is the HTML / CSS / JavaScript code the users interact with
33
40
*[Server](#server-api) - this is an optional server side script that provides endpoints the UI can call
34
41
35
-
## Project Layout
42
+
###Project Layout
36
43
37
44
A custom UI should be published under a directory named `homebridge-ui`:
38
45
@@ -55,7 +62,7 @@ homebridge-example-plugin/
55
62
56
63
You may customise the location of the `homebridge-ui` by setting the `customUiPath` property in the `config.schema.json`. For example: `"customUiPath": "./dist/homebridge-ui"`.
57
64
58
-
# User Interface API
65
+
##User Interface API
59
66
60
67
A plugin's custom user interface is displayed inside an iframe in the settings modal, in place of the schema-generated form.
Toast notifications are the pop-up notifications displayed in the bottom right corner. A plugin's custom UI can generate custom notifications with custom content.
The `homebridge` object is an [EventTarget](https://developer.mozilla.org/en-US/docs/Web/API/EventTarget), this allows you to use the browsers built in [addEventListener](https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener) and [removeEventListener](https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/removeEventListener) functions to subscribe and unsubscribe from events.
401
408
402
-
### Ready Event
409
+
####Ready Event
403
410
404
411
Called when the Homebridge UI has completed rendering the plugin's custom UI.
console.log(response); // the response from the server
559
566
```
560
567
561
-
## Request Error Handling
568
+
###Request Error Handling
562
569
563
570
If you need to throw an error during your request, you should throw an instance of `RequestError` instead of a normal `Error`:
564
571
@@ -587,9 +594,9 @@ try {
587
594
588
595
Uncaught errors in event handlers, or errors thrown using `new Error` will still result in the waiting promise in the UI being rejected, however the error stack trace will also be shown in the Homebridge logs which should be avoided.
@@ -624,7 +631,7 @@ Returns the Homebridge instance's current storage path.
624
631
const storagePath =this.homebridgeStoragePath;
625
632
```
626
633
627
-
### `this.homebridgeConfigPath`
634
+
####`this.homebridgeConfigPath`
628
635
629
636
> `this.homebridgeConfigPath: string`
630
637
@@ -634,7 +641,7 @@ Returns the path to the Homebridge `config.json` file:
634
641
const configPath =this.homebridgeConfigPath;
635
642
```
636
643
637
-
### `this.homebridgeUiVersion`
644
+
####`this.homebridgeUiVersion`
638
645
639
646
> `this.homebridgeUiVersion: string`
640
647
@@ -644,38 +651,38 @@ Returns the version of the Homebridge UI:
644
651
const uiVersion =this.homebridgeUiVersion;
645
652
```
646
653
647
-
# Examples
654
+
##Examples
648
655
649
656
*[Basic Example](./examples/basic-ui-server) - demos a minimal custom user interface, interacting with server side scripts, updating the plugin config, and using toast notifications.
650
657
*[Push Events](./examples/push-events) - demos how to send push events from the server, and listen for them in the custom user interface.
651
658
652
659
653
660
A full list of plugins that have implemented the custom user interface can be found [here](https://www.npmjs.com/package/@homebridge/plugin-ui-utils?activeTab=dependents).
654
661
655
-
#### homebridge-mercedesme
662
+
#####homebridge-mercedesme
656
663
657
664
The [homebridge-mercedesme](https://github.com/SeydX/homebridge-mercedesme) plugin by [@SeydX](https://github.com/SeydX) allows users to pair their vehicle using a custom user interface:
The [homebridge-bravia-tvos](https://github.com/SeydX/homebridge-bravia-tvos) plugin by [@SeydX](https://github.com/SeydX) allows users to pair and dynamically configure a user's TV using a custom user interface:
The [homebridge-electra-smart](https://github.com/nitaybz/homebridge-electra-smart) plugin by [nitaybz](https://github.com/nitaybz) allows users to request a OTP and enter it in exchange for an authentication token:
0 commit comments