From c3570a70656df87fc93acba751ad1bb41df21228 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Mon, 30 Nov 2026 11:38:03 -0500 Subject: [PATCH 1/2] Filter the Marketplace on integration connectivity Integrations can set how they connect, like Zigbee, Bluetooth or cloud. The Marketplace now shows this connectivity: - A connectivity filter pane in the repository table. It lists only the connectivity that the repositories of the tab have, with the names and icons that Home Assistant gives. A picked connectivity is kept in the URL and in My Home Assistant links, like the integration categories. - A connectivity column in the table, hidden by default. - Chips on the repository page that link to the other integrations with the same connectivity. The page loads the icons only for a repository that has a connectivity. Co-Authored-By: Claude Opus 5.5 --- src/common/url/marketplace-query-params.ts | 2 +- src/data/icons.ts | 32 +++++- src/data/integration_connectivity.ts | 15 +++ src/data/marketplace/repository.ts | 3 + src/data/translation.ts | 3 +- .../dashboards/dashboard-repositories.ts | 35 +++++- .../dashboards/ha-marketplace-dashboard.ts | 108 +++++++++++++++++- .../ha-marketplace-repository-dashboard.ts | 79 ++++++++++++- .../marketplace/ha-panel-marketplace.ts | 7 +- src/panels/my/ha-panel-my.ts | 1 + src/translations/en.json | 4 +- test/data/integration_connectivity.test.ts | 29 +++++ .../dashboard-repositories.test.ts | 56 +++++++++ .../marketplace/repository-dashboard.test.ts | 30 ++++- 14 files changed, 387 insertions(+), 17 deletions(-) create mode 100644 src/data/integration_connectivity.ts create mode 100644 test/data/integration_connectivity.test.ts diff --git a/src/common/url/marketplace-query-params.ts b/src/common/url/marketplace-query-params.ts index 14819cb2029b..3e5a8f31a7a1 100644 --- a/src/common/url/marketplace-query-params.ts +++ b/src/common/url/marketplace-query-params.ts @@ -9,7 +9,7 @@ import { // The filters of the Marketplace tables. Search, sorting and grouping are kept // by the data table, see data-table-query-params. export const marketplaceFilterQueryParamConfig = { - list: ["status", "type", "source", "integration_category"], + list: ["status", "type", "source", "integration_category", "connectivity"], } as const satisfies QueryParamConfig; export type MarketplaceFilterQueryParams = QueryParamValues< diff --git a/src/data/icons.ts b/src/data/icons.ts index 8053fdc348f2..24c0804d8616 100644 --- a/src/data/icons.ts +++ b/src/data/icons.ts @@ -250,13 +250,16 @@ export type IconCategory = | "services" | "triggers" | "conditions" - | "integration_category"; + | "integration_category" + | "integration_connectivity"; export type IntegrationCategoryIcons = Record< string, { default: string; subcategory?: Record } >; +export type IntegrationConnectivityIcons = Record; + interface CategoryType { entity: PlatformIcons; entity_component: ComponentIcons; @@ -264,6 +267,7 @@ interface CategoryType { triggers: TriggerIcons; conditions: ConditionIcons; integration_category: IntegrationCategoryIcons; + integration_connectivity: IntegrationConnectivityIcons; } export const getHassIcons = async ( @@ -334,7 +338,10 @@ export const getComponentIcons = async ( export const getCategoryIcons = async < T extends Exclude< IconCategory, - "entity" | "entity_component" | "integration_category" + | "entity" + | "entity_component" + | "integration_category" + | "integration_connectivity" >, >( connection: Connection, @@ -775,3 +782,24 @@ export const getIntegrationCategoryIcons = async ( return undefined; } }; + +let integrationConnectivityIcons: + ReturnType> | undefined; + +export const getIntegrationConnectivityIcons = async ( + connection: Connection +): Promise => { + // Cache the request itself, so callers while it loads share it + integrationConnectivityIcons ??= getHassIcons( + connection, + "integration_connectivity", + "homeassistant" + ); + try { + const result = await integrationConnectivityIcons; + return result.resources.homeassistant; + } catch (_err) { + integrationConnectivityIcons = undefined; + return undefined; + } +}; diff --git a/src/data/integration_connectivity.ts b/src/data/integration_connectivity.ts new file mode 100644 index 000000000000..3d9fecb579b7 --- /dev/null +++ b/src/data/integration_connectivity.ts @@ -0,0 +1,15 @@ +import type { LocalizeFunc } from "../common/translations/localize"; +import type { IntegrationConnectivityIcons } from "./icons"; + +// The name of a connectivity, like `zigbee`. Empty for one this Home Assistant +// doesn't know. +export const integrationConnectivityName = ( + localize: LocalizeFunc, + slug: string +): string => + localize(`component.homeassistant.integration_connectivity.${slug}.name`); + +export const integrationConnectivityIcon = ( + icons: IntegrationConnectivityIcons | undefined, + slug: string +): string | undefined => icons?.[slug]?.default; diff --git a/src/data/marketplace/repository.ts b/src/data/marketplace/repository.ts index 9b63e54c1820..fac82a894924 100644 --- a/src/data/marketplace/repository.ts +++ b/src/data/marketplace/repository.ts @@ -10,6 +10,9 @@ export interface RepositoryBase { can_install: boolean; category: RepositoryType; config_flow: boolean; + // How an integration connects, like `zigbee` or `cloud`. Empty for other + // repositories and for integrations that don't set it. + connectivity?: string[]; custom: boolean; description: string; domain: string | null; diff --git a/src/data/translation.ts b/src/data/translation.ts index 6d484dc9436d..533e4275a960 100644 --- a/src/data/translation.ts +++ b/src/data/translation.ts @@ -77,7 +77,8 @@ export type TranslationCategory = | "services" | "triggers" | "conditions" - | "integration_category"; + | "integration_category" + | "integration_connectivity"; export const subscribeTranslationPreferences = ( hass: HomeAssistant, diff --git a/src/panels/marketplace/dashboards/dashboard-repositories.ts b/src/panels/marketplace/dashboards/dashboard-repositories.ts index ae049eae5fe3..1c4db79ff78f 100644 --- a/src/panels/marketplace/dashboards/dashboard-repositories.ts +++ b/src/panels/marketplace/dashboards/dashboard-repositories.ts @@ -18,6 +18,7 @@ import { inIntegrationCategory, integrationCategoryName, } from "../../../data/integration_category"; +import { integrationConnectivityName } from "../../../data/integration_connectivity"; import type { RepositoryBase } from "../../../data/marketplace/repository"; import type { HomeAssistant } from "../../../types"; import type { MarketplaceTab } from "./ha-marketplace-dashboard"; @@ -45,6 +46,9 @@ export const SOURCE_FILTER = "source"; // Like `energy`, which takes in its subcategories, or `energy.solar` export const INTEGRATION_CATEGORY_FILTER = "integration_category"; +// How an integration connects, like `zigbee` or `cloud` +export const CONNECTIVITY_FILTER = "connectivity"; + // Where a repository comes from, the community catalog or added from a link export const SOURCE_ORDER = ["catalog", "custom"] as const; @@ -59,7 +63,8 @@ export type RepositoryFilters = Partial< | typeof STATUS_FILTER | typeof TYPE_FILTER | typeof SOURCE_FILTER - | typeof INTEGRATION_CATEGORY_FILTER, + | typeof INTEGRATION_CATEGORY_FILTER + | typeof CONNECTIVITY_FILTER, string[] > >; @@ -139,12 +144,14 @@ export const statusesOfTab = ( // The filters are kept for every tab. A status picked on another tab that this // one can't list is left out here, instead of leaving the table empty. So is -// an integration category nothing on this tab is in, when the ones it lists -// are given. Before the repositories load it lists none, so the URL keeps them. +// an integration category or connectivity nothing on this tab has, when the +// ones it lists are given. Before the repositories load it lists none, so the +// URL keeps them. export const filtersOfTab = ( filters: RepositoryFilters, tab: MarketplaceTab, - integrationCategories?: readonly string[] + integrationCategories?: readonly string[], + connectivity?: readonly string[] ): RepositoryFilters => { const statuses: readonly string[] = statusesOfTab(tab); @@ -158,6 +165,11 @@ export const filtersOfTab = ( integrationCategories.includes(slug) ) : filters[INTEGRATION_CATEGORY_FILTER], + [CONNECTIVITY_FILTER]: connectivity + ? filters[CONNECTIVITY_FILTER]?.filter((slug) => + connectivity.includes(slug) + ) + : filters[CONNECTIVITY_FILTER], }; }; @@ -215,6 +227,15 @@ const matchesFilters = ( return false; } + const connectivity = filters[CONNECTIVITY_FILTER]; + + if ( + connectivity?.length && + !connectivity.some((slug) => repository.connectivity?.includes(slug)) + ) { + return false; + } + return true; }; @@ -263,6 +284,11 @@ export const filterRepositories = ( .map((slug) => integrationCategoryName(localize, slug)) .filter(Boolean) .join(", "), + // Ones this Home Assistant doesn't know are left out + translated_connectivity: (repository.connectivity ?? []) + .map((slug) => integrationConnectivityName(localize, slug)) + .filter(Boolean) + .join(", "), // A date as text or 0 without one, only numbers sort among each other last_updated_timestamp: timestamp(repository.last_updated), })); @@ -328,6 +354,7 @@ export const browseLinkFromUrl = ( [SOURCE_FILTER]: lists.source?.filter(Boolean), [INTEGRATION_CATEGORY_FILTER]: lists.integration_category?.filter(Boolean), + [CONNECTIVITY_FILTER]: lists.connectivity?.filter(Boolean), }, }; }; diff --git a/src/panels/marketplace/dashboards/ha-marketplace-dashboard.ts b/src/panels/marketplace/dashboards/ha-marketplace-dashboard.ts index e2fcaf7cf277..0de3897c81e7 100644 --- a/src/panels/marketplace/dashboards/ha-marketplace-dashboard.ts +++ b/src/panels/marketplace/dashboards/ha-marketplace-dashboard.ts @@ -96,6 +96,7 @@ import { haStyle } from "../../../resources/styles"; import { applySkippedUpdates, browseLinkFromUrl, + CONNECTIVITY_FILTER, INTEGRATION_CATEGORY_FILTER, filterRepositories, filtersOfTab, @@ -116,12 +117,22 @@ import type { } from "./dashboard-repositories"; import { documentationUrl } from "../../../util/documentation-url"; import { renderRepositoryIcon } from "../tools/repository-icon"; -import type { IntegrationCategoryIcons } from "../../../data/icons"; -import { getIntegrationCategoryIcons } from "../../../data/icons"; +import type { + IntegrationCategoryIcons, + IntegrationConnectivityIcons, +} from "../../../data/icons"; +import { + getIntegrationCategoryIcons, + getIntegrationConnectivityIcons, +} from "../../../data/icons"; import { integrationCategoryIcon, integrationCategoryName, } from "../../../data/integration_category"; +import { + integrationConnectivityIcon, + integrationConnectivityName, +} from "../../../data/integration_connectivity"; import { showAlertDialog, showConfirmationDialog, @@ -212,6 +223,8 @@ export class HaMarketplaceDashboard extends LitElement { @state() private _integrationCategoryIcons?: IntegrationCategoryIcons; + @state() private _connectivityIcons?: IntegrationConnectivityIcons; + @state() @consumeEntityStates({ entityIdPath: ["_marketplaceUpdateEntityIds"] }) private _states?: HassEntities; @@ -301,6 +314,11 @@ export class HaMarketplaceDashboard extends LitElement { getIntegrationCategoryIcons(this._connection.connection).then((icons) => { this._integrationCategoryIcons = icons; }); + getIntegrationConnectivityIcons(this._connection.connection).then( + (icons) => { + this._connectivityIcons = icons; + } + ); } // The states of these are only selected after this runs, so the skipped @@ -372,10 +390,12 @@ export class HaMarketplaceDashboard extends LitElement { this.tab ); const integrationCategoryStates = this._tabIntegrationCategoryStates(); + const connectivityStates = this._tabConnectivityStates(); const filters = this._filtersOfTab( this._filters, this.tab, - this._stateValues(integrationCategoryStates) + this._stateValues(integrationCategoryStates), + this._connectivityStateValues(connectivityStates) ); const repositories = this._filterRepositories( tabRepositories, @@ -509,6 +529,20 @@ export class HaMarketplaceDashboard extends LitElement { >` : nothing } + ${ + connectivityStates.length + ? html`` + : nothing + } option.value) ); + // Its own cache, so the integration category values stay the same array + private _connectivityStateValues = memoize((options: { value: string }[]) => + options.map((option) => option.value) + ); + private _columns = memoize( ( localizeFunc: LocalizeFunc, @@ -769,6 +808,13 @@ export class HaMarketplaceDashboard extends LitElement { hidden: false, defaultHidden: true, }, + // Few custom integrations set their connectivity yet, so it starts hidden + translated_connectivity: { + ...defaultKeyData, + title: localizeFunc("ui.panel.marketplace.column.connectivity"), + hidden: false, + defaultHidden: true, + }, description: defaultKeyData, authors: defaultKeyData, domain: defaultKeyData, @@ -1143,6 +1189,36 @@ export class HaMarketplaceDashboard extends LitElement { ); } + // Only what the repositories have, the list of all of them is long + private _connectivityStates = memoize( + ( + repositories: RepositoryBase[], + localize: LocalizeFunc, + icons: IntegrationConnectivityIcons | undefined + ) => + [ + ...new Set( + repositories.flatMap((repository) => repository.connectivity ?? []) + ), + ] + .map((slug) => ({ + value: slug, + label: integrationConnectivityName(localize, slug), + icon: integrationConnectivityIcon(icons, slug), + })) + // Ones this Home Assistant doesn't know are left out + .filter((option) => option.label) + .sort((a, b) => a.label.localeCompare(b.label)) + ); + + private _tabConnectivityStates() { + return this._connectivityStates( + this._repositoriesOfTab(this._marketplaceRepositories(), this.tab), + this._i18n.localize, + this._connectivityIcons + ); + } + private _sourceStates = memoize((localize: LocalizeFunc) => SOURCE_ORDER.map((source) => ({ value: source, @@ -1264,6 +1340,32 @@ export class HaMarketplaceDashboard extends LitElement { this._writeFilters(); } + private _connectivityFilterChanged(ev: CustomEvent<{ value: string[] }>) { + const listed = this._connectivityStateValues(this._tabConnectivityStates()); + const filters = { + ...this._filters, + [CONNECTIVITY_FILTER]: paneFilterOfTab( + this._filters[CONNECTIVITY_FILTER], + listed, + ev.detail.value + ), + }; + + if (this._isUserChange(filters)) { + this._storageFilters = { + ...this._storageFilters, + [CONNECTIVITY_FILTER]: paneFilterOfTab( + this._storageFilters[CONNECTIVITY_FILTER], + listed, + ev.detail.value + ), + }; + } + + this._filters = filters; + this._writeFilters(); + } + private _handleCollapseChanged( ev: HASSDomEvent ) { diff --git a/src/panels/marketplace/dashboards/ha-marketplace-repository-dashboard.ts b/src/panels/marketplace/dashboards/ha-marketplace-repository-dashboard.ts index a4bafc31ce90..fb52a5186c7b 100644 --- a/src/panels/marketplace/dashboards/ha-marketplace-repository-dashboard.ts +++ b/src/panels/marketplace/dashboards/ha-marketplace-repository-dashboard.ts @@ -39,12 +39,22 @@ import "../../../components/ha-icon"; import "../../../components/ha-icon-button"; import "../../../components/ha-svg-icon"; import { getConfigEntries } from "../../../data/config_entries"; -import type { IntegrationCategoryIcons } from "../../../data/icons"; -import { getIntegrationCategoryIcons } from "../../../data/icons"; +import type { + IntegrationCategoryIcons, + IntegrationConnectivityIcons, +} from "../../../data/icons"; +import { + getIntegrationCategoryIcons, + getIntegrationConnectivityIcons, +} from "../../../data/icons"; import { integrationCategoryIcon, integrationCategoryName, } from "../../../data/integration_category"; +import { + integrationConnectivityIcon, + integrationConnectivityName, +} from "../../../data/integration_connectivity"; import { apiContext, brandsAccessTokenContext, @@ -103,6 +113,7 @@ import { installBlockedReason } from "../tools/install-blocked-reason"; import { typeIcon } from "../tools/type-icon"; import { browseUrl, + CONNECTIVITY_FILTER, INTEGRATION_CATEGORY_FILTER, } from "./dashboard-repositories"; import { isCommunityOrganization, repositoryAuthors } from "../tools/authors"; @@ -178,6 +189,8 @@ export class HaMarketplaceRepositoryDashboard extends LitElement { @state() private _integrationCategoryIcons?: IntegrationCategoryIcons; + @state() private _connectivityIcons?: IntegrationConnectivityIcons; + @state() @consumeEntityState({ entityIdPath: ["_repository", "update_entity_id"] }) private _updateEntity?: UpdateEntity; @@ -200,6 +213,8 @@ export class HaMarketplaceRepositoryDashboard extends LitElement { private _loadingIntegrationCategoryIcons = false; + private _loadingConnectivityIcons = false; + protected async firstUpdated( changedProperties: PropertyValues ): Promise { @@ -347,6 +362,13 @@ export class HaMarketplaceRepositoryDashboard extends LitElement { ) { this._loadIntegrationCategoryIcons(); } + + if ( + changedProps.has("_repository") && + this._repository?.connectivity?.length + ) { + this._loadConnectivityIcons(); + } } protected updated(changedProps: PropertyValues): void { @@ -419,6 +441,21 @@ export class HaMarketplaceRepositoryDashboard extends LitElement { } } + // Only integrations have a connectivity, other repositories don't need them + private async _loadConnectivityIcons(): Promise { + if (this._connectivityIcons || this._loadingConnectivityIcons) { + return; + } + this._loadingConnectivityIcons = true; + try { + this._connectivityIcons = await getIntegrationConnectivityIcons( + this._connection.connection + ); + } finally { + this._loadingConnectivityIcons = false; + } + } + private _loadRepositoryFromRoute(): void { const repositoryId = repositoryIdFromRoute(this.route); if (!repositoryId) { @@ -642,6 +679,7 @@ export class HaMarketplaceRepositoryDashboard extends LitElement { : nothing } ${this._renderIntegrationCategories(repository)} + ${this._renderConnectivity(repository)} ${this._renderStatus(repository)} `; @@ -681,6 +719,40 @@ export class HaMarketplaceRepositoryDashboard extends LitElement { `; } + // Each links to the other integrations that connect the same way + private _renderConnectivity(repository: RepositoryInfo) { + const connectivity = (repository.connectivity ?? []) + .map((slug) => ({ + slug, + name: integrationConnectivityName(this._i18n.localize, slug), + icon: integrationConnectivityIcon(this._connectivityIcons, slug), + })) + // Ones this Home Assistant doesn't know are left out + .filter((item) => item.name); + + if (!connectivity.length) { + return nothing; + } + + return html` + ${connectivity.map( + (item) => + html` + ${ + item.icon + ? html`` + : nothing + } + ` + )} + `; + } + // Where it stands, and the one thing to do next private _renderStatus(repository: RepositoryInfo) { const status = this._status(repository); @@ -1165,7 +1237,8 @@ type: module`, .description { margin-block: var(--ha-space-4) 0; } - .categories { + .categories, + .connectivity { margin-block-start: var(--ha-space-4); } .status { diff --git a/src/panels/marketplace/ha-panel-marketplace.ts b/src/panels/marketplace/ha-panel-marketplace.ts index 9e2c7bcd62ef..643975864e0c 100644 --- a/src/panels/marketplace/ha-panel-marketplace.ts +++ b/src/panels/marketplace/ha-panel-marketplace.ts @@ -301,8 +301,13 @@ class HaPanelMarketplace extends SubscribeMixin(LitElement) { private _loadBackendTranslations() { // The panel translates the errors of the backend itself this.hass.loadBackendTranslation("exceptions", "marketplace"); - // The categories of custom integrations, the names come with Home Assistant + // The categories and connectivity of custom integrations, the names come + // with Home Assistant this.hass.loadBackendTranslation("integration_category", "homeassistant"); + this.hass.loadBackendTranslation( + "integration_connectivity", + "homeassistant" + ); } private _subscribeMarketplace(): void { diff --git a/src/panels/my/ha-panel-my.ts b/src/panels/my/ha-panel-my.ts index 97a58cf65ed4..e3d996abfe7c 100644 --- a/src/panels/my/ha-panel-my.ts +++ b/src/panels/my/ha-panel-my.ts @@ -52,6 +52,7 @@ const marketplaceTableParams = { status: "string?", source: "string?", integration_category: "string?", + connectivity: "string?", sort: "string?", direction: "string?", group: "string?", diff --git a/src/translations/en.json b/src/translations/en.json index 46d9b30aaef4..a5d3b4becb2b 100644 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -13622,6 +13622,7 @@ "type": "Type", "source": "Source", "integration_categories": "Categories", + "connectivity": "Connectivity", "last_updated": "Activity", "actions": "Actions" }, @@ -13637,7 +13638,8 @@ "status": "Status", "type": "Type", "source": "Source", - "integration_category": "Category" + "integration_category": "Category", + "connectivity": "Connectivity" }, "dialog_custom_repositories": { "title": "Add from a GitHub link", diff --git a/test/data/integration_connectivity.test.ts b/test/data/integration_connectivity.test.ts new file mode 100644 index 000000000000..b42f345a9edb --- /dev/null +++ b/test/data/integration_connectivity.test.ts @@ -0,0 +1,29 @@ +import { describe, expect, it } from "vitest"; +import type { LocalizeFunc } from "../../src/common/translations/localize"; +import { + integrationConnectivityIcon, + integrationConnectivityName, +} from "../../src/data/integration_connectivity"; + +describe("integrationConnectivityName", () => { + const localize = ((key: string) => key) as LocalizeFunc; + + it("names a connectivity", () => { + expect(integrationConnectivityName(localize, "zigbee")).toBe( + "component.homeassistant.integration_connectivity.zigbee.name" + ); + }); +}); + +describe("integrationConnectivityIcon", () => { + const icons = { zigbee: { default: "mdi:zigbee" } }; + + it("finds the icon of a connectivity", () => { + expect(integrationConnectivityIcon(icons, "zigbee")).toBe("mdi:zigbee"); + }); + + it("has none for an unknown connectivity, or without icons", () => { + expect(integrationConnectivityIcon(icons, "matter")).toBeUndefined(); + expect(integrationConnectivityIcon(undefined, "zigbee")).toBeUndefined(); + }); +}); diff --git a/test/panels/marketplace/dashboard-repositories.test.ts b/test/panels/marketplace/dashboard-repositories.test.ts index 3a3095b6ef3f..4d7e7ecbab10 100644 --- a/test/panels/marketplace/dashboard-repositories.test.ts +++ b/test/panels/marketplace/dashboard-repositories.test.ts @@ -154,6 +154,41 @@ describe("filterRepositories", () => { ); }); + it.each([ + [{ connectivity: ["zigbee"] }, ["Bulb", "Hub"]], + [{ connectivity: ["cloud", "zigbee"] }, ["Bulb", "Hub", "Weather"]], + [{ connectivity: ["matter"] }, []], + [{ connectivity: [] }, ["Bulb", "Hub", "Plain", "Weather"]], + ])("keeps the connectivity that matches %j", (activeFilters, expected) => { + expect( + names( + filterRepositories( + [ + repository("Plain"), + repository("Bulb", { connectivity: ["zigbee"] }), + repository("Hub", { connectivity: ["cloud", "zigbee"] }), + repository("Weather", { connectivity: ["cloud"] }), + ], + localize, + activeFilters + ) + ) + ).toEqual(expected); + }); + + it("adds the names of the connectivity, without unknown ones", () => { + const connectivityNames = { + "component.homeassistant.integration_connectivity.cloud.name": "Cloud", + "component.homeassistant.integration_connectivity.zigbee.name": "Zigbee", + }; + const [row] = filterRepositories( + [repository("Hub", { connectivity: ["zigbee", "unknown", "cloud"] })], + ((key: string) => connectivityNames[key] ?? "") as unknown as LocalizeFunc + ); + + expect(row.translated_connectivity).toBe("Zigbee, Cloud"); + }); + it("puts installed first, then new, then the most starred, then by name", () => { const sorted = filterRepositories( [ @@ -242,6 +277,7 @@ describe("browseUrl", () => { type: ["theme"], source: ["custom"], integration_category: ["energy.solar_batteries"], + connectivity: ["zigbee"], }, }), "http://localhost" @@ -257,6 +293,7 @@ describe("browseUrl", () => { type: ["theme"], source: ["custom"], integration_category: ["energy.solar_batteries"], + connectivity: ["zigbee"], }, }); }); @@ -285,6 +322,13 @@ describe("browseLinkFromUrl", () => { }); }); + it("reads a link that only filters on a connectivity", () => { + expect(browseLinkFromUrl("?connectivity=zigbee")).toEqual({ + search: "", + filters: { connectivity: ["zigbee"] }, + }); + }); + it("keeps what was picked for a link that says nothing about browsing", () => { expect( browseLinkFromUrl("?owner=hacs&repository=integration") @@ -308,6 +352,18 @@ describe("filtersOfTab", () => { ); }); + it("leaves out a connectivity nothing on the tab has", () => { + const filters = { connectivity: ["cloud", "zigbee"] }; + + expect( + filtersOfTab(filters, "installed", undefined, ["zigbee"]).connectivity + ).toEqual(["zigbee"]); + // Without the ones the tab lists, as before the repositories load + expect(filtersOfTab(filters, "installed").connectivity).toEqual( + filters.connectivity + ); + }); + it("keeps an integration category picked on browse when the installed pane changes", () => { const picked = ["energy.solar", "climate"]; diff --git a/test/panels/marketplace/repository-dashboard.test.ts b/test/panels/marketplace/repository-dashboard.test.ts index 64019e755cc1..9024e69336c9 100644 --- a/test/panels/marketplace/repository-dashboard.test.ts +++ b/test/panels/marketplace/repository-dashboard.test.ts @@ -11,7 +11,10 @@ import { provideHass } from "../../../src/fake_data/provide_hass"; import { deferred } from "./dialog-host"; import { markdownWithRepositoryContext } from "../../../src/panels/marketplace/tools/markdown"; import type * as MarkdownModule from "../../../src/panels/marketplace/tools/markdown"; -import { getIntegrationCategoryIcons } from "../../../src/data/icons"; +import { + getIntegrationCategoryIcons, + getIntegrationConnectivityIcons, +} from "../../../src/data/icons"; import type * as IconsModule from "../../../src/data/icons"; // The real components need more browser than jsdom has, the page only hands @@ -44,6 +47,7 @@ vi.mock( vi.mock("../../../src/data/icons", async (importOriginal) => ({ ...(await importOriginal()), getIntegrationCategoryIcons: vi.fn(async () => ({})), + getIntegrationConnectivityIcons: vi.fn(async () => ({})), })); vi.mock("../../../src/components/chips/ha-assist-chip", () => stubElement("ha-assist-chip") @@ -242,6 +246,30 @@ describe("ha-marketplace-repository-dashboard", () => { expect(getIntegrationCategoryIcons).toHaveBeenCalledTimes(1); }); + it("loads the connectivity icons once, only for repositories with a connectivity", async () => { + const { page } = await openRepositoryPage( + async (repositoryId) => + repositoryInfo( + repositoryId, + repositoryId === "theme" + ? { category: "theme" } + : { category: "integration", connectivity: ["zigbee"] } + ), + repositoryRoute("theme") + ); + await settle(page); + expect(getIntegrationConnectivityIcons).not.toHaveBeenCalled(); + + page.route = repositoryRoute("1"); + await settle(page); + page.route = repositoryRoute("2"); + await settle(page); + page.reloadRepository(); + await settle(page); + + expect(getIntegrationConnectivityIcons).toHaveBeenCalledTimes(1); + }); + it("clears the error of the previous repository", async () => { const { page } = await openRepositoryPage(async (repositoryId) => { if (repositoryId === "1") { From 2d1f36d1f57dc9f251ed873548c6e83032c85ecb Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Mon, 30 Nov 2026 14:34:00 -0500 Subject: [PATCH 2/2] Show connectivity in the Marketplace demo Co-Authored-By: Claude Opus 5.5 --- demo/src/stubs/marketplace.ts | 10 ++++++++++ demo/src/stubs/translations.ts | 7 ++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/demo/src/stubs/marketplace.ts b/demo/src/stubs/marketplace.ts index dcf69a66e397..edb1ab422132 100644 --- a/demo/src/stubs/marketplace.ts +++ b/demo/src/stubs/marketplace.ts @@ -22,6 +22,14 @@ const baseRepository = { status: "default" as const, }; +// The names of the connectivity of the demo repositories. Home Assistant +// translates them, the mocked hass has no backend translations. +export const marketplaceBackendTranslations = { + "component.homeassistant.integration_connectivity.mqtt.name": "MQTT", + "component.homeassistant.integration_connectivity.network.name": + "Local network", +}; + const repositories: RepositoryBase[] = [ { ...baseRepository, @@ -32,6 +40,7 @@ const repositories: RepositoryBase[] = [ description: "Watch camera streams with low latency through WebRTC.", authors: ["@AlexxIT"], domain: "webrtc", + connectivity: ["network"], config_flow: true, available_version: "v3.6.1", downloads: 98000, @@ -68,6 +77,7 @@ const repositories: RepositoryBase[] = [ description: "Use the cameras and events of a Frigate NVR.", authors: ["@blakeblackshear", "@dermotduffy", "@NickM-27"], domain: "frigate", + connectivity: ["network", "mqtt"], config_flow: true, available_version: "v5.9.0", installed: true, diff --git a/demo/src/stubs/translations.ts b/demo/src/stubs/translations.ts index 632d9ff0194c..fafbdad4f165 100644 --- a/demo/src/stubs/translations.ts +++ b/demo/src/stubs/translations.ts @@ -1,6 +1,7 @@ import type { LocalizeFunc } from "../../../src/common/translations/localize"; import type { MockHomeAssistant } from "../../../src/fake_data/provide_hass"; import { connectivityBackendTranslations } from "./connectivity/fixtures"; +import { marketplaceBackendTranslations } from "./marketplace"; export const mockTranslations = ( hass: MockHomeAssistant, @@ -20,7 +21,11 @@ export const mockTranslations = ( // this merges on top of them. (localizePromise ?? Promise.resolve()).then(() => hass.addTranslations( - Object.assign({}, ...Object.values(connectivityBackendTranslations)) + Object.assign( + {}, + ...Object.values(connectivityBackendTranslations), + marketplaceBackendTranslations + ) ) ); };