Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/components/ha-snowflakes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ export class HaSnowflakes extends SubscribeMixin(LitElement) {
this.hass!.connection,
"frontend",
"winter_mode",
(enabled) => {
this._enabled = enabled;
(feature) => {
this._enabled = feature.enabled;
}
),
];
Expand Down
20 changes: 8 additions & 12 deletions src/data/labs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,22 +101,18 @@ export const subscribeLabFeatures = (
* Subscribe to a specific lab feature
* @param conn - The connection to the Home Assistant instance
* @param domain - The domain of the lab feature
* @param previewFeature - The preview feature of the lab feature
* @param previewFeature - The preview feature identifier
* @param onChange - The function to call when the lab feature changes
* @returns The unsubscribe function
* @returns A promise that resolves to the unsubscribe function
*/
export const subscribeLabFeature = (
conn: Connection,
domain: string,
previewFeature: string,
onChange: (enabled: boolean) => void
) =>
subscribeLabFeatures(conn, (features) => {
const enabled =
features.find(
(feature) =>
feature.domain === domain &&
feature.preview_feature === previewFeature
)?.enabled ?? false;
onChange(enabled);
onChange: (feature: LabPreviewFeature) => void
): Promise<() => void> =>
conn.subscribeMessage<LabPreviewFeature>(onChange, {
type: "labs/subscribe",
domain,
preview_feature: previewFeature,
});
8 changes: 4 additions & 4 deletions src/panels/config/automation/add-automation-element-dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ class DialogAddAutomationElement

private _unsub?: Promise<UnsubscribeFunc>;

private _unsubscribeLabFeatures?: UnsubscribeFunc;
private _unsubscribeLabFeatures?: Promise<UnsubscribeFunc>;

private _configEntryLookup: Record<string, ConfigEntry> = {};

Expand Down Expand Up @@ -285,8 +285,8 @@ class DialogAddAutomationElement
this.hass.connection,
"automation",
"new_triggers_conditions",
(enabled) => {
this._newTriggersAndConditions = enabled;
(feature) => {
this._newTriggersAndConditions = feature.enabled;
this._tab = this._newTriggersAndConditions ? "targets" : "groups";
}
);
Expand Down Expand Up @@ -422,7 +422,7 @@ class DialogAddAutomationElement
this._unsub = undefined;
}
if (this._unsubscribeLabFeatures) {
this._unsubscribeLabFeatures();
this._unsubscribeLabFeatures.then((unsub) => unsub());
this._unsubscribeLabFeatures = undefined;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ export default class HaAutomationCondition extends SubscribeMixin(LitElement) {
this.hass!.connection,
"automation",
"new_triggers_conditions",
(enabled) => {
this._newTriggersAndConditions = enabled;
(feature) => {
this._newTriggersAndConditions = feature.enabled;
}
),
];
Expand Down
4 changes: 2 additions & 2 deletions src/panels/config/automation/trigger/ha-automation-trigger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ export default class HaAutomationTrigger extends SubscribeMixin(LitElement) {
this.hass!.connection,
"automation",
"new_triggers_conditions",
(enabled) => {
this._newTriggersAndConditions = enabled;
(feature) => {
this._newTriggersAndConditions = feature.enabled;
}
),
];
Expand Down
Loading