Skip to content

Commit

Permalink
fix: ignore entities by their hidden and disabled state
Browse files Browse the repository at this point in the history
fixes #23
  • Loading branch information
t0bst4r committed Oct 29, 2024
1 parent fe234f2 commit 9e7b641
Showing 1 changed file with 27 additions and 7 deletions.
34 changes: 27 additions & 7 deletions packages/backend/src/home-assistant/home-assistant-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,33 @@ export class HomeAssistantClient
});
const registry = await getRegistry(this.connection);
this._registry = _.fromPairs(
_.toPairs(registry).filter(([, item]) => {
const hasState = !!item.initialState;
if (!hasState) {
this.log.warn("%s does not have an initial-state", item.entity_id);
}
return hasState;
}),
_.toPairs(registry)
.filter(([, item]) => {
const isHidden = item.hidden_by != undefined;
const isDisabled = item.disabled_by != undefined;
if (isHidden) {
this.log.debug(
"%s is hidden by %s",
item.entity_id,
item.hidden_by,
);
}
if (isDisabled) {
this.log.debug(
"%s is disabled by %s",
item.entity_id,
item.disabled_by,
);
}
return !isHidden && !isDisabled;
})
.filter(([, item]) => {
const hasState = !!item.initialState;
if (!hasState) {
this.log.warn("%s does not have an initial-state", item.entity_id);
}
return hasState;
}),
);

this.subscriptions = {};
Expand Down

0 comments on commit 9e7b641

Please sign in to comment.