node-red-contrib-homebridge-automation 0.2.2-beta.6 → 0.3.0-beta.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-red-contrib-homebridge-automation",
3
- "version": "0.2.2-beta.6",
3
+ "version": "0.3.0-beta.0",
4
4
  "description": "NodeRED Automation for HomeBridge",
5
5
  "main": "src/HAP-NodeRed.js",
6
6
  "scripts": {
@@ -54,10 +54,13 @@ class HBConfigNode {
54
54
  async handleReady() {
55
55
  const updatedDevices = await this.hapClient.getAllServices();
56
56
  if (this.debug && updatedDevices && updatedDevices.length) {
57
- const fs = require('fs');
58
- const storagePath = path.join(__dirname, '/homebridge-automation-endpoints.json');
59
- this.warn(`Writing Homebridge endpoints to ${storagePath}`);
60
- fs.writeFileSync(storagePath, JSON.stringify(updatedDevices, null, 2));
57
+ try {
58
+ const storagePath = path.join(process.cwd(), '/homebridge-automation-endpoints.json');
59
+ this.warn(`Writing Homebridge endpoints to ${storagePath}`);
60
+ fs.writeFileSync(storagePath, JSON.stringify(updatedDevices, null, 2));
61
+ } catch (e) {
62
+ this.error(`Error writing Homebridge endpoints to file: ${e.message}`);
63
+ }
61
64
  }
62
65
  // Fix broken uniqueId's from HAP-Client
63
66
  updatedDevices.forEach((service) => {