-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
20240627.0 #21192
20240627.0 #21192
Changes from all commits
b2a55dd
7aa005e
7603fa3
49c42fc
5273293
fd64d17
da2865d
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 | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -11,6 +11,7 @@ import { | |||||||||||||||||||||||||||||||
fetchEntitySourcesWithCache, | ||||||||||||||||||||||||||||||||
} from "../../data/entity_sources"; | ||||||||||||||||||||||||||||||||
import type { DeviceSelector } from "../../data/selector"; | ||||||||||||||||||||||||||||||||
import { ConfigEntry, getConfigEntries } from "../../data/config_entries"; | ||||||||||||||||||||||||||||||||
import { | ||||||||||||||||||||||||||||||||
filterSelectorDevices, | ||||||||||||||||||||||||||||||||
filterSelectorEntities, | ||||||||||||||||||||||||||||||||
|
@@ -27,6 +28,8 @@ export class HaDeviceSelector extends LitElement { | |||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
@state() private _entitySources?: EntitySources; | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
@state() private _configEntries?: ConfigEntry[]; | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
@property() public value?: any; | ||||||||||||||||||||||||||||||||
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. Address the use of Using - @property() public value?: any;
+ @property() public value?: DeviceRegistryEntry[] | DeviceRegistryEntry; Committable suggestion
Suggested change
ToolsBiome
|
||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
@property() public label?: string; | ||||||||||||||||||||||||||||||||
|
@@ -75,6 +78,12 @@ export class HaDeviceSelector extends LitElement { | |||||||||||||||||||||||||||||||
this._entitySources = sources; | ||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
if (!this._configEntries && this._hasIntegration(this.selector)) { | ||||||||||||||||||||||||||||||||
this._configEntries = []; | ||||||||||||||||||||||||||||||||
getConfigEntries(this.hass).then((entries) => { | ||||||||||||||||||||||||||||||||
this._configEntries = entries; | ||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
Comment on lines
+81
to
+86
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. Ensure proper handling of asynchronous operations. The method to fetch configuration entries is correctly implemented using promises. However, consider adding error handling for the promise to manage potential failures in fetching the configuration entries. getConfigEntries(this.hass).then((entries) => {
this._configEntries = entries;
+ }).catch((error) => {
+ console.error("Failed to fetch configuration entries:", error);
+ this._configEntries = [];
+ }); Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
protected render() { | ||||||||||||||||||||||||||||||||
|
@@ -123,7 +132,9 @@ export class HaDeviceSelector extends LitElement { | |||||||||||||||||||||||||||||||
const deviceIntegrations = this._entitySources | ||||||||||||||||||||||||||||||||
? this._deviceIntegrationLookup( | ||||||||||||||||||||||||||||||||
this._entitySources, | ||||||||||||||||||||||||||||||||
Object.values(this.hass.entities) | ||||||||||||||||||||||||||||||||
Object.values(this.hass.entities), | ||||||||||||||||||||||||||||||||
Object.values(this.hass.devices), | ||||||||||||||||||||||||||||||||
this._configEntries | ||||||||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||||||||
: undefined; | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
|
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.
Ensure proper handling of asynchronous operations.
The method to fetch configuration entries is correctly implemented using promises. However, consider adding error handling for the promise to manage potential failures in fetching the configuration entries.
Committable suggestion