hass-taste-test 0.2.3 → 0.2.5

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 CHANGED
File without changes
package/lib/index.d.ts CHANGED
@@ -25,7 +25,7 @@ export declare class HomeAssistant<E> {
25
25
  private accessToken;
26
26
  private options;
27
27
  private dashboards;
28
- private entitiesCollection;
28
+ private entities;
29
29
  ws: hass.Connection;
30
30
  private constructor();
31
31
  private path_confFile;
package/lib/index.js CHANGED
@@ -56,7 +56,7 @@ class HomeAssistant {
56
56
  accessToken;
57
57
  options;
58
58
  dashboards = 0;
59
- entitiesCollection;
59
+ entities = {};
60
60
  ws;
61
61
  constructor(options) {
62
62
  this.venvDir = (0, path_1.join)((0, os_1.tmpdir)(), 'hasstest-venv');
@@ -186,7 +186,7 @@ class HomeAssistant {
186
186
  const installed = await this.hassVersion();
187
187
  if (!installed || installed !== this.cache.latestHass) {
188
188
  await exec(this.path_pip(), ['install', '--upgrade', 'wheel']);
189
- await exec(this.path_pip(), ['install', '--upgrade', 'mutagen', 'homeassistant']);
189
+ await exec(this.path_pip(), ['install', '--upgrade', 'homeassistant']);
190
190
  }
191
191
  }
192
192
  async readCache() {
@@ -249,7 +249,7 @@ class HomeAssistant {
249
249
  this.accessCode = login.auth_code;
250
250
  await this.launchWebsocket(this.accessCode);
251
251
  // Step through the onboarding pages
252
- await this.post('/api/onboarding/core_config', {}, true);
252
+ await this.post('/api/onboarding/core_config', undefined, true);
253
253
  await this.post('/api/onboarding/analytics', {}, true);
254
254
  const response = await this.post('/api/onboarding/integration', { redirect_uri: this.url + '/?auth_callback=1' }, true);
255
255
  this.accessCode = response.auth_code;
@@ -276,7 +276,7 @@ class HomeAssistant {
276
276
  'Content-Type': 'application/json',
277
277
  ...(authorize ? { Authorization: 'Bearer ' + this.accessToken } : undefined),
278
278
  },
279
- body: JSON.stringify({ client_id: this.clientId, ...body }),
279
+ body: body ? JSON.stringify({ client_id: this.clientId, ...body }) : undefined,
280
280
  });
281
281
  return (await response.json());
282
282
  }
@@ -321,13 +321,15 @@ class HomeAssistant {
321
321
  auth,
322
322
  createSocket: async () => (0, socket_1.createSocket)(auth, false),
323
323
  });
324
- this.entitiesCollection = (0, home_assistant_js_websocket_1.entitiesColl)(this.ws);
324
+ (0, home_assistant_js_websocket_1.subscribeEntities)(this.ws, (e) => (this.entities = { ...this.entities, ...e }));
325
325
  }
326
326
  async addIntegration(name) {
327
327
  const response = await this.post('/api/config/config_entries/flow', {
328
328
  handler: name,
329
329
  show_advanced_options: false,
330
330
  }, true);
331
+ if (response.message)
332
+ throw new Error(`Error configuring ${name} integration. Check the logs: ${response.message}`);
331
333
  if (!response.result)
332
334
  throw new Error('Multi-step integration flows are not yet suppoted');
333
335
  return response.result;
@@ -386,10 +388,7 @@ class HomeAssistant {
386
388
  return new this.HassDashboard(this, dashboard, config, page);
387
389
  }
388
390
  async states() {
389
- console.log(this.entitiesCollection.state);
390
- // this.entitiesCollection = entitiesColl(this.ws);
391
- await this.entitiesCollection.refresh();
392
- return this.entitiesCollection.state;
391
+ return this.entities;
393
392
  }
394
393
  /** Clean up connections and stop the HomeAssistant server */
395
394
  async close() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hass-taste-test",
3
- "version": "0.2.3",
3
+ "version": "0.2.5",
4
4
  "description": "Integration testing for Home Assistant cards",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {