@cecnic1989/homebridge-roborock-mower 0.2.0 → 0.2.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.
@@ -42,6 +42,26 @@
42
42
  }
43
43
  }
44
44
 
45
+ // A freshly installed plugin has no platform block yet; without one Homebridge never starts the platform.
46
+ let platformBlockUnsaved = false;
47
+
48
+ async function ensurePlatformBlock() {
49
+ const configs = await homebridge.getPluginConfig();
50
+ if (configs.length > 0) {
51
+ return;
52
+ }
53
+ await homebridge.updatePluginConfig([{ platform: 'RoborockMower' }]);
54
+ platformBlockUnsaved = true;
55
+ }
56
+
57
+ async function savePlatformBlockIfNew() {
58
+ if (!platformBlockUnsaved) {
59
+ return;
60
+ }
61
+ await homebridge.savePluginConfig();
62
+ platformBlockUnsaved = false;
63
+ }
64
+
45
65
  async function render() {
46
66
  let email = null;
47
67
  try {
@@ -89,6 +109,7 @@
89
109
  try {
90
110
  await request('/auth/verify-code', { email: $('email').value.trim(), code, ...pending });
91
111
  pending = null;
112
+ await savePlatformBlockIfNew();
92
113
  homebridge.toast.success('Signed in. Restart Homebridge to apply.');
93
114
  await render();
94
115
  } catch (error) {
@@ -106,6 +127,7 @@
106
127
  await render();
107
128
  });
108
129
 
130
+ await ensurePlatformBlock();
109
131
  homebridge.showSchemaForm();
110
132
  await render();
111
133
  })();
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@cecnic1989/homebridge-roborock-mower",
3
3
  "displayName": "Homebridge Roborock Mower",
4
4
  "type": "module",
5
- "version": "0.2.0",
5
+ "version": "0.2.1",
6
6
  "description": "Homebridge plugin for Roborock RockMow robot lawn mowers",
7
7
  "author": "cecnic1989",
8
8
  "license": "Apache-2.0",