1
0
mirror of https://github.com/home-assistant/frontend.git synced 2026-04-02 08:33:31 +01:00

Add token for brands url in hassUrl helper (#30111)

This commit is contained in:
Paul Bottein
2026-03-12 11:27:43 +01:00
committed by GitHub
parent 3260c48130
commit d496b2a6fe
4 changed files with 8 additions and 13 deletions

View File

@@ -15,7 +15,6 @@ import { iconColorCSS } from "../../common/style/icon_color_css";
import { cameraUrlWithWidthHeight } from "../../data/camera";
import { CLIMATE_HVAC_ACTION_TO_MODE } from "../../data/climate";
import type { HomeAssistant } from "../../types";
import { addBrandsAuth } from "../../util/brands-url";
import "../ha-state-icon";
@customElement("state-badge")
@@ -141,7 +140,6 @@ export class StateBadge extends LitElement {
if (this.hass) {
imageUrl = this.hass.hassUrl(imageUrl);
}
imageUrl = addBrandsAuth(imageUrl, this.hass?.auth.data.hassUrl);
if (domain === "camera") {
imageUrl = cameraUrlWithWidthHeight(imageUrl, 80, 80);
}

View File

@@ -18,7 +18,6 @@ import "../../../components/ha-svg-icon";
import { cameraUrlWithWidthHeight } from "../../../data/camera";
import type { ActionHandlerEvent } from "../../../data/lovelace/action_handler";
import type { HomeAssistant } from "../../../types";
import { addBrandsAuth } from "../../../util/brands-url";
import { actionHandler } from "../common/directives/action-handler-directive";
import { computeLovelaceEntityName } from "../common/entity/compute-lovelace-entity-name";
import { findEntities } from "../common/find-entities";
@@ -144,10 +143,7 @@ export class HuiEntityBadge extends LitElement implements LovelaceBadge {
if (!entityPicture) return undefined;
let imageUrl = addBrandsAuth(
this.hass!.hassUrl(entityPicture),
this.hass?.auth.data.hassUrl
);
let imageUrl = this.hass!.hassUrl(entityPicture);
if (computeStateDomain(stateObj) === "camera") {
imageUrl = cameraUrlWithWidthHeight(imageUrl, 32, 32);
}

View File

@@ -21,7 +21,6 @@ import { cameraUrlWithWidthHeight } from "../../../data/camera";
import type { ActionHandlerEvent } from "../../../data/lovelace/action_handler";
import "../../../state-display/state-display";
import type { HomeAssistant } from "../../../types";
import { addBrandsAuth } from "../../../util/brands-url";
import "../card-features/hui-card-features";
import type { LovelaceCardFeatureContext } from "../card-features/types";
import { computeLovelaceEntityName } from "../common/entity/compute-lovelace-entity-name";
@@ -159,10 +158,7 @@ export class HuiTileCard extends LitElement implements LovelaceCard {
if (!entityPicture) return undefined;
let imageUrl = addBrandsAuth(
this.hass!.hassUrl(entityPicture),
this.hass?.auth.data.hassUrl
);
let imageUrl = this.hass!.hassUrl(entityPicture);
if (computeDomain(entity.entity_id) === "camera") {
imageUrl = cameraUrlWithWidthHeight(imageUrl, 80, 80);
}

View File

@@ -31,6 +31,7 @@ import { subscribeFloorRegistry } from "../data/ws-floor_registry";
import { subscribePanels } from "../data/ws-panels";
import { translationMetadata } from "../resources/translations-metadata";
import {
addBrandsAuth,
clearBrandsTokenRefresh,
fetchAndScheduleBrandsAccessToken,
} from "../util/brands-url";
@@ -88,7 +89,11 @@ export const connectionMixin = <T extends Constructor<HassBaseEl>>(
suspendWhenHidden: true,
enableShortcuts: true,
moreInfoEntityId: null,
hassUrl: (path = "") => new URL(path, auth.data.hassUrl).toString(),
hassUrl: (path = "") =>
addBrandsAuth(
new URL(path, auth.data.hassUrl).toString(),
auth.data.hassUrl
),
callService: async (
domain,
service,