-
Notifications
You must be signed in to change notification settings - Fork 3.7k
include entities not in entity registry in config entities #4867
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,7 +3,7 @@ import "@polymer/paper-dropdown-menu/paper-dropdown-menu"; | |
| import "@polymer/paper-item/paper-icon-item"; | ||
| import "@polymer/paper-listbox/paper-listbox"; | ||
| import "@polymer/paper-tooltip/paper-tooltip"; | ||
| import { UnsubscribeFunc } from "home-assistant-js-websocket"; | ||
| import { UnsubscribeFunc, HassEntities } from "home-assistant-js-websocket"; | ||
| import { | ||
| css, | ||
| CSSResult, | ||
|
|
@@ -22,7 +22,6 @@ import { stateIcon } from "../../../common/entity/state_icon"; | |
| import { | ||
| DataTableColumnContainer, | ||
| DataTableColumnData, | ||
| HaDataTable, | ||
| RowClickedEvent, | ||
| SelectionChangedEvent, | ||
| } from "../../../components/data-table/ha-data-table"; | ||
|
|
@@ -47,6 +46,10 @@ import { | |
| } from "./show-dialog-entity-registry-detail"; | ||
| import { configSections } from "../ha-panel-config"; | ||
| import { classMap } from "lit-html/directives/class-map"; | ||
| import { computeStateName } from "../../../common/entity/compute_state_name"; | ||
| import { fireEvent } from "../../../common/dom/fire_event"; | ||
| // tslint:disable-next-line: no-duplicate-imports | ||
| import { HaTabsSubpageDataTable } from "../../../layouts/hass-tabs-subpage-data-table"; | ||
|
|
||
| @customElement("ha-config-entities") | ||
| export class HaConfigEntities extends SubscribeMixin(LitElement) { | ||
|
|
@@ -57,9 +60,11 @@ export class HaConfigEntities extends SubscribeMixin(LitElement) { | |
| @property() private _entities?: EntityRegistryEntry[]; | ||
| @property() private _showDisabled = false; | ||
| @property() private _showUnavailable = true; | ||
| @property() private _showReadOnly = true; | ||
| @property() private _filter = ""; | ||
| @property() private _selectedEntities: string[] = []; | ||
| @query("ha-data-table") private _dataTable!: HaDataTable; | ||
| @query("hass-tabs-subpage-data-table") | ||
| private _dataTable!: HaTabsSubpageDataTable; | ||
| private getDialog?: () => DialogEntityRegistryDetail | undefined; | ||
|
|
||
| private _columns = memoize( | ||
|
|
@@ -90,7 +95,7 @@ export class HaConfigEntities extends SubscribeMixin(LitElement) { | |
| sortable: true, | ||
| filterable: true, | ||
| template: (_status, entity: any) => | ||
| entity.unavailable || entity.disabled_by | ||
| entity.unavailable || entity.disabled_by || entity.readonly | ||
| ? html` | ||
| <div | ||
| tabindex="0" | ||
|
|
@@ -102,15 +107,21 @@ export class HaConfigEntities extends SubscribeMixin(LitElement) { | |
| })} | ||
| .icon=${entity.unavailable | ||
| ? "hass:alert-circle" | ||
| : "hass:cancel"} | ||
| : entity.disabled_by | ||
| ? "hass:cancel" | ||
| : "hass:pencil-off"} | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like the pencil-off icon, good choice. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the icon truly needed? The entity's check box is grayed-out, signalling read-only status. A quick glance on the left already indicates which entities can/cannot be edited. The no-edit icon repeats on the right what is already communicated on the left. Whereas the exclamation icon draws one's attention to an anomaly (entity is unavailable), lacking a unique_id isn't an anomalous condition but shares the same column.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A user needs to know why the checkbox is disabled, there is no explanation now. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree. However, I don't believe the pencil-off icon provides that missing explanation. It simply reiterates the meaning of the dimmed checkbox: this table-row cannot be edited. Suggestion:
Anyway, I don't mean to belabor the point but, in its current form, it tells me twice that I can't edit the table-row (and without a hint as to why).
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It does show that it is not editable on click in the settings dialog.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Check the screenshot, it does tell you why. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Your original post's edit-history shows the screenshot was added 3 days ago, same time when I made my previous post. My mistake; I didn't see you had amended your original post. I suggest the message also mention BTW, I believe the message's text should use the conjunctive adverb
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It doesn't necessarily have to be in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. True, but all entities defined in FWIW, the few flow-based integrations I've used (Homekit_controller, LIFX, and the currently in-beta UPB) all generate entities with unique_id's. This gave me the impression that it's the norm for flow-based integrations. Off-topic: As for the Hue integration, without knowing why it fails to generate unique id's (a design constraint?), I'd say it's anomalous (and probably should create them).
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well every integration should try to do it, also a lot of integrations that are set up with |
||
| ></ha-icon> | ||
| <paper-tooltip position="left"> | ||
| ${entity.unavailable | ||
| ? this.hass.localize( | ||
| "ui.panel.config.entities.picker.status.unavailable" | ||
| ) | ||
| : this.hass.localize( | ||
| : entity.disabled_by | ||
| ? this.hass.localize( | ||
| "ui.panel.config.entities.picker.status.disabled" | ||
| ) | ||
| : this.hass.localize( | ||
| "ui.panel.config.entities.picker.status.readonly" | ||
| )} | ||
| </paper-tooltip> | ||
| </div> | ||
|
|
@@ -156,18 +167,38 @@ export class HaConfigEntities extends SubscribeMixin(LitElement) { | |
| private _filteredEntities = memoize( | ||
| ( | ||
| entities: EntityRegistryEntry[], | ||
| states: HassEntities, | ||
| showDisabled: boolean, | ||
| showUnavailable: boolean | ||
| showUnavailable: boolean, | ||
| showReadOnly: boolean | ||
| ) => { | ||
| let stateEntities: EntityRegistryEntry[] = []; | ||
| if (showReadOnly) { | ||
| const regEntityIds = entities.map((entity) => entity.entity_id); | ||
|
bramkragten marked this conversation as resolved.
Outdated
|
||
| const stateEntityIds = Object.keys(states).filter( | ||
| (entityId) => !regEntityIds.includes(entityId) | ||
| ); | ||
| stateEntities = stateEntityIds.map((entityId) => { | ||
|
bramkragten marked this conversation as resolved.
Outdated
|
||
| return { | ||
| name: computeStateName(states[entityId]), | ||
| entity_id: entityId, | ||
| platform: computeDomain(entityId), | ||
| disabled_by: null, | ||
| readonly: true, | ||
| selectable: false, | ||
|
bramkragten marked this conversation as resolved.
|
||
| }; | ||
| }); | ||
| } | ||
|
|
||
| if (!showDisabled) { | ||
| entities = entities.filter((entity) => !Boolean(entity.disabled_by)); | ||
| } | ||
|
|
||
| return entities.reduce((result, entry) => { | ||
| const state = this.hass!.states[entry.entity_id]; | ||
| return entities.concat(stateEntities).reduce((result, entry) => { | ||
|
bramkragten marked this conversation as resolved.
Outdated
|
||
| const state = states[entry.entity_id]; | ||
|
|
||
| const unavailable = | ||
| state && (state.state === "unavailable" || state.attributes.restored); // if there is not state it is disabled | ||
| state && (state.state === "unavailable" || state.attributes.restored); | ||
|
bramkragten marked this conversation as resolved.
Outdated
|
||
|
|
||
| if (!showUnavailable && unavailable) { | ||
| return result; | ||
|
|
@@ -322,6 +353,15 @@ export class HaConfigEntities extends SubscribeMixin(LitElement) { | |
| "ui.panel.config.entities.picker.filter.show_unavailable" | ||
| )} | ||
| </paper-icon-item> | ||
| <paper-icon-item @tap="${this._showReadOnlyChanged}"> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't know if this should be an option. They are active, they have states etc otherwise they wouldn't exist. I think that we should always show them. |
||
| <paper-checkbox | ||
| .checked=${this._showReadOnly} | ||
| slot="item-icon" | ||
| ></paper-checkbox> | ||
| ${this.hass!.localize( | ||
| "ui.panel.config.entities.picker.filter.show_readonly" | ||
| )} | ||
| </paper-icon-item> | ||
| </paper-listbox> | ||
| </paper-menu-button> | ||
| `; | ||
|
|
@@ -336,8 +376,10 @@ export class HaConfigEntities extends SubscribeMixin(LitElement) { | |
| .columns=${this._columns(this.narrow, this.hass.language)} | ||
| .data=${this._filteredEntities( | ||
| this._entities, | ||
| this.hass.states, | ||
| this._showDisabled, | ||
| this._showUnavailable | ||
| this._showUnavailable, | ||
| this._showReadOnly | ||
| )} | ||
| .filter=${this._filter} | ||
| selectable | ||
|
|
@@ -369,6 +411,10 @@ export class HaConfigEntities extends SubscribeMixin(LitElement) { | |
| this._showUnavailable = !this._showUnavailable; | ||
| } | ||
|
|
||
| private _showReadOnlyChanged() { | ||
| this._showReadOnly = !this._showReadOnly; | ||
| } | ||
|
|
||
| private _handleSearchChange(ev: CustomEvent) { | ||
| this._filter = ev.detail.value; | ||
| } | ||
|
|
@@ -466,6 +512,7 @@ export class HaConfigEntities extends SubscribeMixin(LitElement) { | |
| (entity) => entity.entity_id === entryId | ||
| ); | ||
| if (!entry) { | ||
| fireEvent(this, "hass-more-info", { entityId: entryId }); | ||
|
bramkragten marked this conversation as resolved.
Outdated
|
||
| return; | ||
| } | ||
| this.getDialog = showEntityRegistryDetailDialog(this, { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this very limiting on mobile ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This shouldn't have been in this PR 🙈 but, no It just makes sure the scroll container fits on the screen, will fine-tune it a bit.