feat: Add or and template folder media matchers (#2071)

- For: #1748
This commit is contained in:
Dermot Duffy
2025-05-29 21:21:59 -07:00
committed by GitHub
parent c077f8bf70
commit dc63dcdab9
25 changed files with 502 additions and 145 deletions
+7 -5
View File
@@ -1,4 +1,5 @@
import { NonEmptyTuple } from 'type-fest';
import { ConditionState } from '../../../conditions/types';
import {
FolderConfig,
folderTypeSchema,
@@ -112,6 +113,7 @@ export class HAFoldersEngine implements FoldersEngine {
public async expandFolder(
hass: HomeAssistant,
query: FolderQuery,
conditionState?: ConditionState,
engineOptions?: EngineOptions,
): Promise<ViewItem[] | null> {
if (query.folder.type !== folderTypeSchema.enum.ha) {
@@ -163,13 +165,13 @@ export class HAFoldersEngine implements FoldersEngine {
...(nextComponent && {
matcher: (media: BrowseMedia) =>
this._mediaMatcher.match(
media,
nextComponent.ha?.matchers,
this._mediaMatcher.match(hass, media, {
matchers: nextComponent.ha?.matchers,
// Set foldersOnly to true if there are more stages in the path,
// as by definition only folders can be matched at this point.
pathComponents.length > 0,
),
foldersOnly: pathComponents.length > 0,
conditionState,
}),
advance: (targets) => (pathComponents.length ? generateStep(targets) : []),
}),
},