homebridge-ecobee-security 0.4.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.4.1
4
+
5
+ - Plugin icon in the README.
6
+ - Catch and log errors creating the storage folder or control socket instead of stopping the bridge.
7
+
3
8
  ## 0.4.0
4
9
 
5
10
  - `offerNight`: adds Night to the Home app; it arms ecobee's Stay and keeps showing Night. Changing
package/README.md CHANGED
@@ -1,3 +1,5 @@
1
+ <p align="center"><img src="icon.png" alt="" width="128" height="128"></p>
2
+
1
3
  # homebridge-ecobee-security
2
4
 
3
5
  Shows **ecobee Smart Security** in Apple Home as a security system: arm **Stay**, arm **Away**,
package/lib/control.js CHANGED
@@ -8,7 +8,11 @@ import { chmodSync, rmSync } from 'node:fs';
8
8
  import { createServer } from 'node:http';
9
9
 
10
10
  export function startControlServer({ path, log, getSystem }) {
11
- rmSync(path, { force: true });
11
+ try {
12
+ rmSync(path, { force: true });
13
+ } catch (error) {
14
+ log.warn(`Could not remove an old control socket ${path}: ${error.message}`);
15
+ }
12
16
  const server = createServer(async (req, res) => {
13
17
  const url = new URL(req.url, 'http://localhost');
14
18
  const by = (url.searchParams.get('by') || 'another plugin').slice(0, 40);
@@ -31,8 +35,14 @@ export function startControlServer({ path, log, getSystem }) {
31
35
  });
32
36
  server.on('error', error => log.error(`Control socket ${path}: ${error.message}`));
33
37
  server.listen(path, () => {
34
- chmodSync(path, 0o600);
35
- log.debug(`Control socket listening at ${path}`);
38
+ try {
39
+ chmodSync(path, 0o600);
40
+ log.debug(`Control socket listening at ${path}`);
41
+ } catch (error) {
42
+ // Only the homebridge user may use the socket; don't serve it if that can't be ensured.
43
+ log.error(`Control socket ${path}: ${error.message}; closing it.`);
44
+ server.close();
45
+ }
36
46
  });
37
47
  return server;
38
48
  }
package/lib/platform.js CHANGED
@@ -28,7 +28,11 @@ export class EcobeeSecurityPlatform {
28
28
  this.cached = [];
29
29
 
30
30
  const dir = join(api.user.storagePath(), 'ecobee-security');
31
- mkdirSync(dir, { recursive: true });
31
+ try {
32
+ mkdirSync(dir, { recursive: true });
33
+ } catch (error) {
34
+ log.error(`Could not create ${dir}: ${error.message}`);
35
+ }
32
36
  this.storePath = join(dir, 'state.json');
33
37
  this.store = this.load();
34
38
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "homebridge-ecobee-security",
3
3
  "displayName": "ecobee Smart Security",
4
- "version": "0.4.0",
4
+ "version": "0.4.1",
5
5
  "description": "ecobee Smart Security as a HomeKit security system: arm Stay / Away, disarm, alarm state (unofficial, ecobee cloud)",
6
6
  "type": "module",
7
7
  "main": "index.js",