hass-taste-test 0.2.3 → 0.2.4

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/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');
@@ -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.4",
4
4
  "description": "Integration testing for Home Assistant cards",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {