hass-taste-test 0.2.4 → 0.2.6
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/lib/bin.js +0 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +10 -6
- package/package.json +1 -1
package/lib/bin.js
CHANGED
|
File without changes
|
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -57,6 +57,7 @@ class HomeAssistant {
|
|
|
57
57
|
options;
|
|
58
58
|
dashboards = 0;
|
|
59
59
|
entities = {};
|
|
60
|
+
started = false;
|
|
60
61
|
ws;
|
|
61
62
|
constructor(options) {
|
|
62
63
|
this.venvDir = (0, path_1.join)((0, os_1.tmpdir)(), 'hasstest-venv');
|
|
@@ -109,8 +110,11 @@ class HomeAssistant {
|
|
|
109
110
|
await fs.writeFile(this.path_cache(), JSON.stringify(this.cache));
|
|
110
111
|
await releaseLock();
|
|
111
112
|
// Step 3: Start Home Assistant and onboard
|
|
112
|
-
this.process = (0, child_process_1.spawn)(this.path_hass(), ['-c', this.configDir, '-v', ...this.options.hassArgs], {
|
|
113
|
-
|
|
113
|
+
this.process = (0, child_process_1.spawn)(this.path_hass(), ['-c', this.configDir, '-v', ...this.options.hassArgs], { stdio: 'pipe' });
|
|
114
|
+
this.process.stderr.on('data', (d) => {
|
|
115
|
+
if (d.includes('Starting Home Assistant'))
|
|
116
|
+
this.started = true;
|
|
117
|
+
process.stderr.write(d);
|
|
114
118
|
});
|
|
115
119
|
this.process.on('error', (e) => {
|
|
116
120
|
console.error(`----\nHome Assistant is having trouble starting. This is likely due to a problem with your virtual environment; try removing the venv folder at ${this.venvDir} and re-running hass-taste-test\n---`);
|
|
@@ -122,7 +126,7 @@ class HomeAssistant {
|
|
|
122
126
|
if (code != 0)
|
|
123
127
|
reject(new Error(`Home Assistant exited with code ${code}`));
|
|
124
128
|
});
|
|
125
|
-
while (!(await this.isUp()))
|
|
129
|
+
while (!this.started || !(await this.isUp()))
|
|
126
130
|
await sleep();
|
|
127
131
|
resolve();
|
|
128
132
|
});
|
|
@@ -186,7 +190,7 @@ class HomeAssistant {
|
|
|
186
190
|
const installed = await this.hassVersion();
|
|
187
191
|
if (!installed || installed !== this.cache.latestHass) {
|
|
188
192
|
await exec(this.path_pip(), ['install', '--upgrade', 'wheel']);
|
|
189
|
-
await exec(this.path_pip(), ['install', '--upgrade', '
|
|
193
|
+
await exec(this.path_pip(), ['install', '--upgrade', 'homeassistant']);
|
|
190
194
|
}
|
|
191
195
|
}
|
|
192
196
|
async readCache() {
|
|
@@ -249,7 +253,7 @@ class HomeAssistant {
|
|
|
249
253
|
this.accessCode = login.auth_code;
|
|
250
254
|
await this.launchWebsocket(this.accessCode);
|
|
251
255
|
// Step through the onboarding pages
|
|
252
|
-
await this.post('/api/onboarding/core_config',
|
|
256
|
+
await this.post('/api/onboarding/core_config', undefined, true);
|
|
253
257
|
await this.post('/api/onboarding/analytics', {}, true);
|
|
254
258
|
const response = await this.post('/api/onboarding/integration', { redirect_uri: this.url + '/?auth_callback=1' }, true);
|
|
255
259
|
this.accessCode = response.auth_code;
|
|
@@ -276,7 +280,7 @@ class HomeAssistant {
|
|
|
276
280
|
'Content-Type': 'application/json',
|
|
277
281
|
...(authorize ? { Authorization: 'Bearer ' + this.accessToken } : undefined),
|
|
278
282
|
},
|
|
279
|
-
body: JSON.stringify({ client_id: this.clientId, ...body }),
|
|
283
|
+
body: body ? JSON.stringify({ client_id: this.clientId, ...body }) : undefined,
|
|
280
284
|
});
|
|
281
285
|
return (await response.json());
|
|
282
286
|
}
|