Digital-Alchemy-TS / hass

Typescript APIs for Home Assistant. Includes rest & websocket bindings
https://docs.digital-alchemy.app
MIT License
8 stars 2 forks source link

Log errors on early calls #31

Closed zoe-codez closed 5 months ago

zoe-codez commented 5 months ago

Changes

Calling hass.entity methods, or hass.call prior to the application initializing will result in an error log onReady, alerting to the incorrect code pattern

function ExampleService({ hass, lifecycle }:TServiceParams) {
  const list = hass.entity.byLabel("my_label"); //  ❌  ERROR LOG!
  lifecycle.onReady(() => {
    const list = hass.entity.byLabel("my_label"); // ✅ 
  });
}

Checklist