Skip to content
This repository was archived by the owner on Apr 28, 2024. It is now read-only.

Commit 7beed68

Browse files
committed
Improvement: webUI enhancements - better error reporting from the API, new first run user exeprience.
1 parent 2ac9aa0 commit 7beed68

File tree

4 files changed

+68
-44
lines changed

4 files changed

+68
-44
lines changed

homebridge-ui/public/index.html

+33-39
Original file line numberDiff line numberDiff line change
@@ -75,51 +75,45 @@
7575
</div>
7676
</div>
7777
<div id="pageSupport" class="mt-4" style="display: none;">
78-
<p class="text-center lead">Thank you for using <strong>homebridge-myq</strong>.</p>
78+
<h5>Introduction</h5>
79+
<p class="px-4">I hope you enjoy <a target="_blank" href="https://github.com/hjdhjd/homebridge-myq">homebridge-myq</a> as much as I enjoy developing it. All my projects are labors of love. If you'd like to show your appreciation - <a target="_blank" href="https://github.com/hjdhjd/homebridge-myq">star this project on Github</A> and do some good in your community, either financially or with your time: a food bank, an animal shelter (two of my passions), or whatever resonates with you that can give something back to the world around you.</p>
7980

80-
<p>Other plugins by <a target="_blank" href="https://github.com/hjdhjd">HJD</a>: </p>
81+
<div class="px-4">
82+
Other plugins by <a target="_blank" href="https://github.com/hjdhjd">HJD</a>:
8183

82-
<ul dir="auto">
83-
<li><a target="_blank" href="https://github.com/hjdhjd/homebridge-unifi-protect">homebridge-unifi-protect: Complete HomeKit integration for the entire UniFi Protect ecosystem</a></li>
84-
</ul>
85-
86-
<p class="text-center lead">Documentation Reference</p>
87-
88-
<h5>Features</h5>
89-
<ul dir="auto">
90-
<li>
91-
Getting Started
9284
<ul dir="auto">
93-
<li>
94-
<a target="_blank" href="https://github.com/hjdhjd/homebridge-myq#installation">Installation</a>: installing this plugin, including system requirements.
95-
</li>
96-
<li>
97-
<a target="_blank" href="https://github.com/hjdhjd/homebridge-myq#plugin-configuration">Plugin Configuration</a>: how to quickly get up and running.
98-
</li>
99-
<li>
100-
<a target="_blank" href="https://github.com/hjdhjd/homebridge-myq#notes">Additional Notes</a>: some things you should be aware of, including myQ-specific quirks.
101-
</li>
85+
<li><a target="_blank" href="https://github.com/hjdhjd/homebridge-unifi-protect">homebridge-unifi-protect: Complete HomeKit integration for the entire UniFi Protect ecosystem</a></li>
10286
</ul>
103-
</li>
104-
<li>
105-
Advanced Topics
106-
<ul dir="auto">
107-
<li>
108-
<a target="_blank" href="https://github.com/hjdhjd/homebridge-myq/blob/main/docs/FeatureOptions.md">Feature Options</a>: granular options to allow you to show or hide specific garage door and gate openers, and more.
109-
</li>
110-
<li>
111-
<a target="_blank" href="https://github.com/hjdhjd/homebridge-myq/blob/main/docs/MQTT.md">MQTT</a>: how to configure MQTT support.
112-
</li>
113-
<li>
114-
<a target="_blank" href="https://github.com/hjdhjd/homebridge-myq/blob/main/docs/AdvancedOptions.md">Advanced Configuration</a>: complete list of configuration options available in this plugin.
115-
</li>
116-
</ul>
117-
</li>
118-
</ul>
87+
</div>
88+
89+
<h5>Getting Started</h5>
90+
<ul dir="auto">
91+
<li>
92+
<a target="_blank" href="https://github.com/hjdhjd/homebridge-myq#installation">Installation</a>: installing this plugin, including system requirements.
93+
</li>
94+
<li>
95+
<a target="_blank" href="https://github.com/hjdhjd/homebridge-myq#plugin-configuration">Plugin Configuration</a>: how to quickly get up and running.
96+
</li>
97+
<li>
98+
<a target="_blank" href="https://github.com/hjdhjd/homebridge-myq#notes">Additional Notes</a>: some things you should be aware of, including myQ-specific quirks.
99+
</li>
100+
</ul>
119101

120-
<h5>Help/About</h5>
102+
<h5>Advanced Topics</h5>
103+
<ul dir="auto">
104+
<li>
105+
<a target="_blank" href="https://github.com/hjdhjd/homebridge-myq/blob/main/docs/FeatureOptions.md">Feature Options</a>: granular options to allow you to show or hide specific garage door and gate openers, and more.
106+
</li>
107+
<li>
108+
<a target="_blank" href="https://github.com/hjdhjd/homebridge-myq/blob/main/docs/MQTT.md">MQTT</a>: how to configure MQTT support.
109+
</li>
110+
<li>
111+
<a target="_blank" href="https://github.com/hjdhjd/homebridge-myq/blob/main/docs/AdvancedOptions.md">Advanced Configuration</a>: complete list of configuration options available in this plugin.
112+
</li>
113+
</ul>
121114

122-
<div>The myQ API has largely stabilized in recent years, particularly with the advent of the v6 version of the API. However, the myQ cloud can (and does) have occasional reliability challenges that can manifest through connectivity issues that you will see in the Homebridge logs related to this plugin. These are not bugs in homebridge-myq and there's not much we can do it aside from attempt to gracefully handle the errors when they occur. The myQ cloud is quite reliable the large majority (~93-95% by my estimate) of the time.<br><br><strong class="text-danger">Please do not open bug reports related to API issues - they'll be closed summarily unless it's a new API-specific issue that's emerged as a result of changes to the undocumented myQ API.</strong></div>
115+
<h5>Support</h5>
116+
<div class="px-4">The myQ API has largely stabilized in recent years, particularly with the advent of the v6 version of the API. However, the myQ cloud can (and does) have occasional reliability challenges that can manifest through connectivity issues that you will see in the Homebridge logs related to this plugin. These are not bugs in homebridge-myq and there's not much we can do it aside from attempt to gracefully handle the errors when they occur. The myQ cloud is quite reliable the large majority (~93-95% by my estimate) of the time.<br><br><strong class="text-danger">Please do not open bug reports related to API issues - they'll be closed summarily unless it's a new API-specific issue that's emerged as a result of changes to the undocumented myQ API.</strong></div>
123117
<br>
124118
<ul>
125119
<li>

homebridge-ui/public/myq-featureoptions.mjs

+2-3
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ export class myQFeatureOptions extends FeatureOptions {
7676
// We haven't configured anything yet - we're done.
7777
if(!this.currentConfig[0]?.email?.length || !this.currentConfig[0]?.password?.length) {
7878

79-
document.getElementById("headerInfo").innerHTML = "Please configure your myQ login credentials in the main settings tab before configuring feature options.";
79+
document.getElementById("headerInfo").innerHTML = "Please configure your myQ login credentials in the settings tab before configuring feature options.";
8080
document.getElementById("headerInfo").style.display = "";
8181
homebridge.hideSpinner();
8282

@@ -143,8 +143,7 @@ export class myQFeatureOptions extends FeatureOptions {
143143
document.getElementById("deviceStatsTable").style.display = "none";
144144
document.getElementById("sidebar").style.display = "none";
145145

146-
document.getElementById("headerInfo").innerHTML = "Unable to connect to the myQ API. Check your username and password in the main settings tab to verify they are correct, or try again later if the myQ API is currently having difficulties.";
147-
146+
document.getElementById("headerInfo").innerHTML = "Unable to connect to the myQ API.<br>Check your username and password in the settings tab to verify they are correct, or try again later if the myQ API is currently having difficulties.<br><code class=\"text-danger\">" + (await homebridge.request("/getErrorMessage")) + "</code>";
148147
document.getElementById("headerInfo").style.display = "";
149148

150149
homebridge.hideSpinner();

homebridge-ui/public/ui.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ async function showFirstRun () {
5555
// Couldn't connect to the myQ API for some reason.
5656
if((myQDevices?.length === 1) && myQDevices[0] === -1) {
5757

58-
tdLoginError.appendChild(document.createTextNode("Unable to login to the myQ API. Please check your email address and password."));
58+
tdLoginError.innerHTML = "Unable to login to the myQ API.<br>Please check your email address and password.<br><code class=\"text-danger\">" + (await homebridge.request("/getErrorMessage")) + "</code>";
5959
homebridge.hideSpinner();
6060
return;
6161
}

homebridge-ui/server.js

+32-1
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,16 @@ import util from "node:util";
1414

1515
class PluginUiServer extends HomebridgePluginUiServer {
1616

17+
errorInfo;
18+
1719
constructor () {
1820
super();
1921

22+
this.errorInfo = "";
23+
24+
// Register getErrorMessage() with the Homebridge server API.
25+
this.#registerGetErrorMessage();
26+
2027
// Register getDevices() with the Homebridge server API.
2128
this.#registerGetDevices();
2229

@@ -26,6 +33,25 @@ class PluginUiServer extends HomebridgePluginUiServer {
2633
this.ready();
2734
}
2835

36+
// Register the getErrorMessage() webUI server API endpoint.
37+
#registerGetErrorMessage() {
38+
39+
// Return the most recent error message generated by the myQ API.
40+
this.onRequest("/getErrorMessage", async () => {
41+
42+
try {
43+
44+
return this.errorInfo;
45+
} catch(err) {
46+
47+
console.log(err);
48+
49+
// Return nothing if we error out for some reason.
50+
return "";
51+
}
52+
});
53+
}
54+
2955
// Register the getDevices() webUI server API endpoint.
3056
#registerGetDevices() {
3157

@@ -37,7 +63,12 @@ class PluginUiServer extends HomebridgePluginUiServer {
3763
const log = {
3864

3965
debug: (message, parameters) => {},
40-
error: (message, parameters = []) => console.error(util.format(message, ...parameters)),
66+
error: (message, parameters = []) => {
67+
68+
// Save the error to inform the user in the webUI.
69+
this.errorInfo = util.format(message, ...parameters);
70+
console.log(this.errorInfo);
71+
},
4172
info: (message, parameters) => {},
4273
warn: (message, parameters = []) => console.log(util.format(message, ...parameters))
4374
};

0 commit comments

Comments
 (0)