mirror of
https://github.com/home-assistant/frontend.git
synced 2026-11-26 14:49:00 +00:00
Compare commits
11
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
00312420d8 | ||
|
|
f2116b61fc | ||
|
|
2e872965f6 | ||
|
|
cbf745f38a | ||
|
|
fe7cedd04b | ||
|
|
2e9d8a1788 | ||
|
|
332d612956 | ||
|
|
11ef852384 | ||
|
|
394d5999b8 | ||
|
|
384fdfdbc9 | ||
|
|
0cccdc5972 |
No files matched your search
@@ -70,6 +70,32 @@ const ENTITIES = [
|
||||
CoverEntityFeature.CLOSE_TILT,
|
||||
},
|
||||
},
|
||||
{
|
||||
entity_id: "cover.tilt_only_closed",
|
||||
state: "closed",
|
||||
attributes: {
|
||||
friendly_name: "Tilt-only blind closed",
|
||||
device_class: "blind",
|
||||
assumed_state: true,
|
||||
supported_features:
|
||||
CoverEntityFeature.OPEN_TILT +
|
||||
CoverEntityFeature.STOP_TILT +
|
||||
CoverEntityFeature.CLOSE_TILT,
|
||||
},
|
||||
},
|
||||
{
|
||||
entity_id: "cover.tilt_only_open",
|
||||
state: "open",
|
||||
attributes: {
|
||||
friendly_name: "Tilt-only blind open",
|
||||
device_class: "blind",
|
||||
assumed_state: true,
|
||||
supported_features:
|
||||
CoverEntityFeature.OPEN_TILT +
|
||||
CoverEntityFeature.STOP_TILT +
|
||||
CoverEntityFeature.CLOSE_TILT,
|
||||
},
|
||||
},
|
||||
{
|
||||
entity_id: "cover.tilt_slider_half",
|
||||
state: "on",
|
||||
|
||||
+2
-2
@@ -126,9 +126,9 @@
|
||||
"matchPackageNames": ["echarts", "zrender"]
|
||||
},
|
||||
{
|
||||
"description": "Group formatjs monorepo package",
|
||||
"description": "Group formatjs monorepo packages",
|
||||
"groupName": "formatjs",
|
||||
"matchPackageNames": ["@formatjs/**"]
|
||||
"matchPackageNames": ["@formatjs/**", "intl-messageformat"]
|
||||
},
|
||||
{
|
||||
"description": "Group Playwright package and CI container updates",
|
||||
|
||||
@@ -235,7 +235,7 @@ export class HaCameraPlayer extends LitElement {
|
||||
const aspectRatio = this._aspectRatio();
|
||||
if (aspectRatio !== this._firedAspectRatio) {
|
||||
this._firedAspectRatio = aspectRatio;
|
||||
fireEvent(this, "camera-aspect-ratio-changed", { aspectRatio });
|
||||
fireEvent(this, "media-size-changed", { aspectRatio });
|
||||
}
|
||||
if (changedProps.has("keepAwake")) {
|
||||
if (this.keepAwake) {
|
||||
@@ -1189,6 +1189,7 @@ declare global {
|
||||
"ha-camera-player": HaCameraPlayer;
|
||||
}
|
||||
interface HASSDomEvents {
|
||||
"camera-aspect-ratio-changed": { aspectRatio: number };
|
||||
/** The natural width limits the picture's width when it is set */
|
||||
"media-size-changed": { aspectRatio: number; naturalWidth?: number };
|
||||
}
|
||||
}
|
||||
@@ -179,6 +179,10 @@ export class HaControlCircularSlider extends LitElement {
|
||||
|
||||
disconnectedCallback(): void {
|
||||
super.disconnectedCallback();
|
||||
this._destroyListeners();
|
||||
if (this._activeSlider) {
|
||||
this._cancelInteraction();
|
||||
}
|
||||
}
|
||||
|
||||
private _managers: HammerManager[] = [];
|
||||
@@ -248,6 +252,18 @@ export class HaControlCircularSlider extends LitElement {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
private _cancelInteraction() {
|
||||
if (this._activeSlider) {
|
||||
fireEvent(this, `${this._activeSlider}-changing`, {
|
||||
value: undefined,
|
||||
});
|
||||
}
|
||||
this._activeSlider = undefined;
|
||||
this._localValue = this.value;
|
||||
this._localLow = this.low;
|
||||
this._localHigh = this.high;
|
||||
}
|
||||
|
||||
private _setupListeners() {
|
||||
if (this._interactions && this._managers.length === 0) {
|
||||
this._interactions.forEach((interaction) => {
|
||||
@@ -279,15 +295,7 @@ export class HaControlCircularSlider extends LitElement {
|
||||
mc.add(new Tap({ event: "singletap" }));
|
||||
|
||||
const cancelInteraction = () => {
|
||||
if (this._activeSlider) {
|
||||
fireEvent(this, `${this._activeSlider}-changing`, {
|
||||
value: undefined,
|
||||
});
|
||||
}
|
||||
this._activeSlider = undefined;
|
||||
this._localValue = this.value;
|
||||
this._localLow = this.low;
|
||||
this._localHigh = this.high;
|
||||
this._cancelInteraction();
|
||||
if (pressToActivate) {
|
||||
panRecognizer.set({ enable: false });
|
||||
}
|
||||
|
||||
@@ -238,6 +238,7 @@ export class HaGridSizeEditor extends LitElement {
|
||||
grid-template-rows: auto auto;
|
||||
grid-template-columns: auto 1fr;
|
||||
gap: var(--ha-space-2);
|
||||
padding-left: var(--ha-space-4);
|
||||
}
|
||||
.precise {
|
||||
grid-area: precise;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import type { TemplateResult } from "lit";
|
||||
import type { PropertyValues, TemplateResult } from "lit";
|
||||
import { LitElement, css, html, nothing } from "lit";
|
||||
import { customElement, property } from "lit/decorators";
|
||||
import { ifDefined } from "lit/directives/if-defined";
|
||||
import type { ActionHandlerOptions } from "../../data/lovelace/action_handler";
|
||||
import { actionHandler } from "../../panels/lovelace/common/directives/action-handler-directive";
|
||||
import { actionHandlerBind } from "../../panels/lovelace/common/directives/action-handler-directive";
|
||||
import "../ha-icon";
|
||||
import "../ha-svg-icon";
|
||||
|
||||
@@ -56,6 +56,11 @@ export class HaTileIcon extends LitElement {
|
||||
return nothing;
|
||||
}
|
||||
|
||||
protected updated(changedProps: PropertyValues<this>): void {
|
||||
super.updated(changedProps);
|
||||
actionHandlerBind(this, this.actionHandlerOptions);
|
||||
}
|
||||
|
||||
protected render(): TemplateResult {
|
||||
const hasImage = Boolean(this.imageUrl);
|
||||
|
||||
@@ -67,7 +72,6 @@ export class HaTileIcon extends LitElement {
|
||||
aria-label=${ifDefined(
|
||||
this.interactive ? this.accessibleLabel : undefined
|
||||
)}
|
||||
.actionHandler=${actionHandler(this.actionHandlerOptions)}
|
||||
>
|
||||
<slot name="icon">${this._renderIcon()}</slot>
|
||||
</div>
|
||||
@@ -94,6 +98,7 @@ export class HaTileIcon extends LitElement {
|
||||
:host([interactive]) {
|
||||
-webkit-tap-highlight-color: transparent;
|
||||
pointer-events: auto;
|
||||
cursor: pointer;
|
||||
}
|
||||
:host([interactive]:active) {
|
||||
transform: scale(1.2);
|
||||
@@ -143,6 +148,9 @@ export class HaTileIcon extends LitElement {
|
||||
transition: color 180ms ease-in-out;
|
||||
pointer-events: none;
|
||||
}
|
||||
::slotted(:not([slot])) {
|
||||
pointer-events: none;
|
||||
}
|
||||
.container img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
|
||||
@@ -5,6 +5,9 @@ import {
|
||||
} from "home-assistant-js-websocket";
|
||||
import type { Store } from "home-assistant-js-websocket/dist/store";
|
||||
import type { DataTableRowData } from "../components/data-table/ha-data-table";
|
||||
import type { HomeAssistant } from "../types";
|
||||
import type { ConfigEntry } from "./config_entries";
|
||||
import type { DeviceRegistryEntry } from "./device/device_registry";
|
||||
|
||||
export interface BluetoothDeviceData extends DataTableRowData {
|
||||
address: string;
|
||||
@@ -74,6 +77,54 @@ export const isScannerStateMismatch = (state: BluetoothScannerState): boolean =>
|
||||
state.requested_mode !== "auto" &&
|
||||
state.current_mode !== state.requested_mode;
|
||||
|
||||
export interface BluetoothAdapterDevice {
|
||||
device: DeviceRegistryEntry;
|
||||
entry: ConfigEntry;
|
||||
}
|
||||
|
||||
/**
|
||||
* Splits the Bluetooth adapters into enabled and disabled ones. An adapter is
|
||||
* a device with a Bluetooth connection that belongs to a `bluetooth` config
|
||||
* entry. Config entries without such a device (for example ignored discoveries
|
||||
* or removed proxies) are not adapters, unless they are disabled, so they can
|
||||
* still be enabled again.
|
||||
*/
|
||||
export const getBluetoothAdapters = (
|
||||
devices: HomeAssistant["devices"],
|
||||
configEntries: ConfigEntry[]
|
||||
) => {
|
||||
const entryMap = new Map(configEntries.map((e) => [e.entry_id, e]));
|
||||
|
||||
const enabledDevices: BluetoothAdapterDevice[] = [];
|
||||
const disabledDevices: BluetoothAdapterDevice[] = [];
|
||||
const matchedEntryIds = new Set<string>();
|
||||
|
||||
for (const device of Object.values(devices)) {
|
||||
const btConnection = device.connections.find((c) => c[0] === "bluetooth");
|
||||
if (!btConnection) {
|
||||
continue;
|
||||
}
|
||||
const entry = device.config_entries
|
||||
.map((id) => entryMap.get(id))
|
||||
.find((e) => e !== undefined);
|
||||
if (!entry) {
|
||||
continue;
|
||||
}
|
||||
matchedEntryIds.add(entry.entry_id);
|
||||
if (entry.disabled_by !== null) {
|
||||
disabledDevices.push({ device, entry });
|
||||
} else {
|
||||
enabledDevices.push({ device, entry });
|
||||
}
|
||||
}
|
||||
|
||||
const disabledEntriesWithoutDevice = configEntries.filter(
|
||||
(e) => e.disabled_by !== null && !matchedEntryIds.has(e.entry_id)
|
||||
);
|
||||
|
||||
return { enabledDevices, disabledDevices, disabledEntriesWithoutDevice };
|
||||
};
|
||||
|
||||
export const subscribeBluetoothScannersDetailsUpdates = (
|
||||
conn: Connection,
|
||||
store: Store<BluetoothScannersDetails>
|
||||
|
||||
+19
-5
@@ -239,12 +239,29 @@ export interface CoverEntity extends HassEntityBase {
|
||||
attributes: CoverEntityAttributes;
|
||||
}
|
||||
|
||||
// For covers that report no value, the open or closed state tells where it is
|
||||
const valueFromState = (stateObj: CoverEntity): number | undefined => {
|
||||
if (stateObj.state === UNKNOWN || stateObj.state === UNAVAILABLE) {
|
||||
return undefined;
|
||||
}
|
||||
return stateObj.state === "closed" || stateObj.state === "opening" ? 0 : 100;
|
||||
};
|
||||
|
||||
export const coverCurrentValue = (
|
||||
stateObj: CoverEntity,
|
||||
mode: CoverControlMode
|
||||
): number | undefined => {
|
||||
if (mode === "tilt") {
|
||||
return stateObj.attributes.current_tilt_position ?? undefined;
|
||||
const tilt = stateObj.attributes.current_tilt_position;
|
||||
// The state only describes the slats when the cover can't move up or down
|
||||
if (
|
||||
tilt != null ||
|
||||
coverSupportsTiltPosition(stateObj) ||
|
||||
coverHasPositionControls(stateObj)
|
||||
) {
|
||||
return tilt ?? undefined;
|
||||
}
|
||||
return valueFromState(stateObj);
|
||||
}
|
||||
const position = stateObj.attributes.current_position;
|
||||
if (
|
||||
@@ -253,10 +270,7 @@ export const coverCurrentValue = (
|
||||
) {
|
||||
return position ?? undefined;
|
||||
}
|
||||
if (stateObj.state === UNKNOWN || stateObj.state === UNAVAILABLE) {
|
||||
return undefined;
|
||||
}
|
||||
return stateObj.state === "closed" || stateObj.state === "opening" ? 0 : 100;
|
||||
return valueFromState(stateObj);
|
||||
};
|
||||
|
||||
declare global {
|
||||
|
||||
@@ -3,8 +3,11 @@ import {
|
||||
mdiImageMultipleOutline,
|
||||
mdiLightningBolt,
|
||||
} from "@mdi/js";
|
||||
import type { ContextType } from "@lit/context";
|
||||
import { css, html, LitElement, nothing } from "lit";
|
||||
import { customElement, state } from "lit/decorators";
|
||||
import { isComponentLoaded } from "../../common/config/is_component_loaded";
|
||||
import { consume } from "../../common/decorators/consume";
|
||||
import { consumeLocalize } from "../../common/decorators/consume-context-entry";
|
||||
import type { LocalizeFunc } from "../../common/translations/localize";
|
||||
import { CAMERA_STREAM_TYPE_NAMES } from "../../components/camera/ha-camera-stream-badge";
|
||||
@@ -21,6 +24,8 @@ import {
|
||||
type CameraStreamType,
|
||||
type StreamType,
|
||||
} from "../../data/camera-streams";
|
||||
import { fetchCloudStatus } from "../../data/cloud";
|
||||
import { apiContext, configContext } from "../../data/context";
|
||||
import { haStyleDialog, haStyleDialogFixedTop } from "../../resources/styles";
|
||||
import { DialogMixin } from "../dialog-mixin";
|
||||
import type { CameraStreamInfoDialogParams } from "./show-dialog-camera-stream-info";
|
||||
@@ -40,6 +45,34 @@ class DialogCameraStreamInfo extends DialogMixin<CameraStreamInfoDialogParams>(
|
||||
@consumeLocalize()
|
||||
private _localize!: LocalizeFunc;
|
||||
|
||||
@consume({ context: apiContext })
|
||||
private _api!: ContextType<typeof apiContext>;
|
||||
|
||||
@consume({ context: configContext })
|
||||
private _hassConfig!: ContextType<typeof configContext>;
|
||||
|
||||
@state() private _cloudIceServers = false;
|
||||
|
||||
protected firstUpdated() {
|
||||
this._fetchCloudIceServers();
|
||||
}
|
||||
|
||||
// The same check that core uses to add the cloud TURN servers
|
||||
private async _fetchCloudIceServers() {
|
||||
if (!isComponentLoaded(this._hassConfig.config, "cloud")) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const status = await fetchCloudStatus(this._api.callWS);
|
||||
this._cloudIceServers =
|
||||
status.logged_in &&
|
||||
status.active_subscription &&
|
||||
status.prefs.cloud_ice_servers_enabled;
|
||||
} catch (_err) {
|
||||
// Without the cloud status the label stays hidden
|
||||
}
|
||||
}
|
||||
|
||||
protected render() {
|
||||
if (!this.params) {
|
||||
return nothing;
|
||||
@@ -124,6 +157,18 @@ class DialogCameraStreamInfo extends DialogMixin<CameraStreamInfoDialogParams>(
|
||||
wrap-supporting-text
|
||||
>
|
||||
<ha-svg-icon slot="start" .path=${icon}></ha-svg-icon>
|
||||
${
|
||||
type === STREAM_TYPE_WEB_RTC && this._cloudIceServers
|
||||
? html`<span slot="headline" class="headline">
|
||||
${CAMERA_STREAM_TYPE_NAMES[type]}
|
||||
<span class="tag cloud"
|
||||
>${this._localize(
|
||||
"ui.dialogs.camera_stream_info.enhanced_by_cloud"
|
||||
)}</span
|
||||
>
|
||||
</span>`
|
||||
: nothing
|
||||
}
|
||||
${
|
||||
current
|
||||
? html`<span slot="end" class="tag current"
|
||||
@@ -188,6 +233,20 @@ class DialogCameraStreamInfo extends DialogMixin<CameraStreamInfoDialogParams>(
|
||||
color: var(--secondary-text-color);
|
||||
}
|
||||
|
||||
.headline {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: var(--ha-space-2);
|
||||
/* The row keeps the headline on one line, but a long tag must wrap */
|
||||
white-space: normal;
|
||||
}
|
||||
|
||||
.tag.cloud {
|
||||
background-color: var(--ha-color-fill-primary-quiet-resting);
|
||||
color: var(--ha-color-on-primary-quiet);
|
||||
}
|
||||
|
||||
.tag.current {
|
||||
background-color: var(--ha-color-fill-success-quiet-resting);
|
||||
color: var(--ha-color-on-success-quiet);
|
||||
|
||||
@@ -2,6 +2,8 @@ import { css, html, LitElement, nothing } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import { consume } from "../../../common/decorators/consume";
|
||||
import { transform } from "../../../common/decorators/transform";
|
||||
import type { HASSDomCurrentTargetEvent } from "../../../common/dom/fire_event";
|
||||
import { fireEvent } from "../../../common/dom/fire_event";
|
||||
import { connectionContext, formattersContext } from "../../../data/context";
|
||||
import type { ImageEntity } from "../../../data/image";
|
||||
import { computeImageUrl } from "../../../data/image";
|
||||
@@ -28,6 +30,17 @@ class MoreInfoImage extends LitElement {
|
||||
|
||||
@property({ attribute: false }) public stateObj?: ImageEntity;
|
||||
|
||||
private _size?: HASSDomEvents["media-size-changed"];
|
||||
|
||||
public connectedCallback() {
|
||||
super.connectedCallback();
|
||||
// A cached view that was detached while the picture loaded couldn't send
|
||||
// its size, and the picture doesn't load again when it's shown
|
||||
if (this._size) {
|
||||
fireEvent(this, "media-size-changed", this._size);
|
||||
}
|
||||
}
|
||||
|
||||
protected render() {
|
||||
if (!this._connection || !this.stateObj) {
|
||||
return nothing;
|
||||
@@ -39,16 +52,28 @@ class MoreInfoImage extends LitElement {
|
||||
return html`<img
|
||||
alt=${this._formatEntityName?.(this.stateObj) || this.stateObj.entity_id}
|
||||
src=${this._connection.hassUrl(imageUrl)}
|
||||
@load=${this._imageLoaded}
|
||||
/> `;
|
||||
}
|
||||
|
||||
private _imageLoaded(ev: HASSDomCurrentTargetEvent<HTMLImageElement>) {
|
||||
const { naturalWidth, naturalHeight } = ev.currentTarget;
|
||||
if (!naturalWidth || !naturalHeight) {
|
||||
return;
|
||||
}
|
||||
this._size = { aspectRatio: naturalWidth / naturalHeight, naturalWidth };
|
||||
fireEvent(this, "media-size-changed", this._size);
|
||||
}
|
||||
|
||||
static styles = css`
|
||||
:host {
|
||||
display: block;
|
||||
text-align: center;
|
||||
}
|
||||
img {
|
||||
display: block;
|
||||
margin: 0 auto;
|
||||
max-width: 100%;
|
||||
max-height: var(--more-info-media-max-height, none);
|
||||
}
|
||||
`;
|
||||
}
|
||||
|
||||
@@ -149,10 +149,12 @@ export class MoreInfoDialog extends DirtyStateProviderMixin<
|
||||
|
||||
@property({ type: Boolean, reflect: true }) public large = false;
|
||||
|
||||
@state() private _fill = false;
|
||||
// The dialog grows with the camera's or image's picture, as high as there
|
||||
// is room for
|
||||
@state() private _mediaAspectRatio?: number;
|
||||
|
||||
// The dialog grows with the camera's picture, as high as there is room for
|
||||
@state() private _cameraAspectRatio?: number;
|
||||
// An image is not shown larger than it is
|
||||
@state() private _mediaNaturalWidth?: number;
|
||||
|
||||
// Height of the controls the camera's info shows below the picture
|
||||
@state() private _cameraControlsHeight?: string;
|
||||
@@ -196,12 +198,6 @@ export class MoreInfoDialog extends DirtyStateProviderMixin<
|
||||
}
|
||||
|
||||
public showDialog(params: MoreInfoDialogParams) {
|
||||
// The camera player keeps running for the same entity and doesn't send
|
||||
// its size again
|
||||
if (params.entityId !== this._entityId) {
|
||||
this._cameraAspectRatio = undefined;
|
||||
this._cameraControlsHeight = undefined;
|
||||
}
|
||||
this._entityId = params.entityId;
|
||||
if (!this._entityId) {
|
||||
this.closeDialog();
|
||||
@@ -219,7 +215,6 @@ export class MoreInfoDialog extends DirtyStateProviderMixin<
|
||||
this._detailsYamlMode = false;
|
||||
|
||||
this.large = params.large ?? false;
|
||||
this._fill = false;
|
||||
this._open = true;
|
||||
this._loadEntityRegistryEntry();
|
||||
}
|
||||
@@ -265,8 +260,6 @@ export class MoreInfoDialog extends DirtyStateProviderMixin<
|
||||
this._currView = DEFAULT_VIEW;
|
||||
this._childViewStack = [];
|
||||
this._returnUrl = undefined;
|
||||
this._cameraAspectRatio = undefined;
|
||||
this._cameraControlsHeight = undefined;
|
||||
this._isEscapeEnabled = true;
|
||||
window.removeEventListener("dialog-closed", this._enableEscapeKeyClose);
|
||||
window.removeEventListener("show-dialog", this._disableEscapeKeyClose);
|
||||
@@ -691,30 +684,32 @@ export class MoreInfoDialog extends DirtyStateProviderMixin<
|
||||
`
|
||||
: nothing;
|
||||
|
||||
// Also when the camera was opened from a smaller entity's related view
|
||||
const cameraAspectRatio =
|
||||
domain === "camera" && isDefaultView
|
||||
? this._cameraAspectRatio
|
||||
// Also when it was opened from a smaller entity's related view
|
||||
const mediaAspectRatio =
|
||||
(domain === "camera" || domain === "image") && isDefaultView
|
||||
? this._mediaAspectRatio
|
||||
: undefined;
|
||||
// As wide as the picture is when it's as high as there is room for
|
||||
const fullHeightWidth = `var(--more-info-media-max-height) * ${mediaAspectRatio}`;
|
||||
const mediaPictureWidth = this._mediaNaturalWidth
|
||||
? `min(${fullHeightWidth}, ${this._mediaNaturalWidth}px)`
|
||||
: fullHeightWidth;
|
||||
|
||||
return html`
|
||||
<ha-adaptive-dialog
|
||||
.open=${this._open}
|
||||
.width=${
|
||||
this._fill
|
||||
? "full"
|
||||
: this.large || cameraAspectRatio
|
||||
? "large"
|
||||
: "medium"
|
||||
}
|
||||
class=${classMap({ camera: domain === "camera" })}
|
||||
.width=${this.large || mediaAspectRatio ? "large" : "medium"}
|
||||
class=${classMap({
|
||||
camera: domain === "camera",
|
||||
image: domain === "image",
|
||||
})}
|
||||
style=${styleMap({
|
||||
"--more-info-camera-controls-height": this._cameraControlsHeight,
|
||||
"--ha-dialog-width-lg": cameraAspectRatio
|
||||
? `clamp(var(--ha-dialog-width-md, 580px), calc(var(--video-max-height) * ${cameraAspectRatio}), 1920px)`
|
||||
"--ha-dialog-width-lg": mediaAspectRatio
|
||||
? `clamp(var(--ha-dialog-width-md, 580px), calc(${mediaPictureWidth} + var(--more-info-media-inline-padding, 0px)), 1920px)`
|
||||
: undefined,
|
||||
})}
|
||||
@camera-aspect-ratio-changed=${this._cameraAspectRatioChanged}
|
||||
@media-size-changed=${this._mediaSizeChanged}
|
||||
@camera-controls-height-changed=${this._cameraControlsHeightChanged}
|
||||
.accessibleLabel=${title}
|
||||
@closed=${this._dialogClosed}
|
||||
@@ -747,7 +742,7 @@ export class MoreInfoDialog extends DirtyStateProviderMixin<
|
||||
></ha-icon-button-prev>
|
||||
`
|
||||
}
|
||||
<span slot="headerTitle" @click=${this._enlarge} class="title">
|
||||
<span slot="headerTitle" class="title">
|
||||
${
|
||||
breadcrumb.length > 0
|
||||
? !__DEMO__ && isAdmin
|
||||
@@ -1071,6 +1066,17 @@ export class MoreInfoDialog extends DirtyStateProviderMixin<
|
||||
`;
|
||||
}
|
||||
|
||||
protected willUpdate(changedProps: PropertyValues) {
|
||||
super.willUpdate(changedProps);
|
||||
// Also when going to a related entity or back. The camera player or image
|
||||
// of the same entity keeps running and doesn't send its size again.
|
||||
if (changedProps.has("_entityId")) {
|
||||
this._mediaAspectRatio = undefined;
|
||||
this._mediaNaturalWidth = undefined;
|
||||
this._cameraControlsHeight = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
protected firstUpdated(changedProps: PropertyValues<this>) {
|
||||
super.firstUpdated(changedProps);
|
||||
this.addEventListener("close-dialog", () => this.closeDialog());
|
||||
@@ -1140,10 +1146,11 @@ export class MoreInfoDialog extends DirtyStateProviderMixin<
|
||||
this._entry = ev.detail;
|
||||
}
|
||||
|
||||
private _cameraAspectRatioChanged(
|
||||
ev: HASSDomEvent<HASSDomEvents["camera-aspect-ratio-changed"]>
|
||||
private _mediaSizeChanged(
|
||||
ev: HASSDomEvent<HASSDomEvents["media-size-changed"]>
|
||||
) {
|
||||
this._cameraAspectRatio = ev.detail.aspectRatio;
|
||||
this._mediaAspectRatio = ev.detail.aspectRatio;
|
||||
this._mediaNaturalWidth = ev.detail.naturalWidth;
|
||||
}
|
||||
|
||||
private _cameraControlsHeightChanged(
|
||||
@@ -1152,12 +1159,6 @@ export class MoreInfoDialog extends DirtyStateProviderMixin<
|
||||
this._cameraControlsHeight = ev.detail.height;
|
||||
}
|
||||
|
||||
private _enlarge() {
|
||||
withViewTransition(() => {
|
||||
this._fill = !this._fill;
|
||||
});
|
||||
}
|
||||
|
||||
private _handleOpened() {
|
||||
window.addEventListener("dialog-closed", this._enableEscapeKeyClose);
|
||||
window.addEventListener("show-dialog", this._disableEscapeKeyClose);
|
||||
@@ -1216,12 +1217,14 @@ export class MoreInfoDialog extends DirtyStateProviderMixin<
|
||||
--dialog-content-padding: 0;
|
||||
}
|
||||
|
||||
/* The dialog's margin, its header of about 68px and the controls
|
||||
below the picture */
|
||||
ha-adaptive-dialog.camera {
|
||||
--video-max-height: calc(
|
||||
100vh - var(--ha-space-20) -
|
||||
68px - var(--more-info-camera-controls-height, 0px)
|
||||
/* The dialog's margin, the safe area like the dialog's height limit,
|
||||
its header of about 68px and what the info shows besides the
|
||||
picture */
|
||||
ha-adaptive-dialog.camera,
|
||||
ha-adaptive-dialog.image {
|
||||
--more-info-media-max-height: calc(
|
||||
100vh - var(--ha-space-20) - var(--safe-area-inset-y, 0px) -
|
||||
68px - var(--more-info-media-reserved-height, 0px)
|
||||
);
|
||||
/* Along with the height of the picture */
|
||||
--ha-dialog-width-transition:
|
||||
@@ -1232,14 +1235,33 @@ export class MoreInfoDialog extends DirtyStateProviderMixin<
|
||||
/* A custom property takes any value, so it can't fall back to the
|
||||
declaration before it. svh like the height limit of the dialog. */
|
||||
@supports (height: 1svh) {
|
||||
ha-adaptive-dialog.camera {
|
||||
--video-max-height: calc(
|
||||
100svh - var(--ha-space-20) -
|
||||
68px - var(--more-info-camera-controls-height, 0px)
|
||||
ha-adaptive-dialog.camera,
|
||||
ha-adaptive-dialog.image {
|
||||
--more-info-media-max-height: calc(
|
||||
100svh - var(--ha-space-20) - var(--safe-area-inset-y, 0px) -
|
||||
68px - var(--more-info-media-reserved-height, 0px)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
ha-adaptive-dialog.camera {
|
||||
--more-info-media-reserved-height: var(
|
||||
--more-info-camera-controls-height,
|
||||
0px
|
||||
);
|
||||
--video-max-height: var(--more-info-media-max-height);
|
||||
}
|
||||
|
||||
/* The info's padding around the picture and the entity's row of 40px
|
||||
above it, with 16px between them */
|
||||
ha-adaptive-dialog.image {
|
||||
--more-info-media-reserved-height: calc(
|
||||
var(--ha-space-6) +
|
||||
max(var(--safe-area-inset-bottom, 0px), var(--ha-space-6)) + 56px
|
||||
);
|
||||
--more-info-media-inline-padding: calc(var(--ha-space-6) * 2);
|
||||
}
|
||||
|
||||
.content-wrapper {
|
||||
flex: 1 1 auto;
|
||||
min-height: 0;
|
||||
|
||||
@@ -95,6 +95,23 @@ class DialogStartupProgress extends DialogMixin(LitElement) {
|
||||
.slice(0, MAX_SLOWEST);
|
||||
});
|
||||
}
|
||||
if (changedProps.has("_progress") || changedProps.has("_setups")) {
|
||||
this._loadTitles();
|
||||
}
|
||||
}
|
||||
|
||||
private _loadTitles() {
|
||||
const progress = this._progress
|
||||
? this._computeProgress(this._progress, this._config.config.state)
|
||||
: undefined;
|
||||
const domains = [
|
||||
...(progress?.active.map(([domain]) => domain) ?? []),
|
||||
...(progress?.failed ?? []),
|
||||
...(this._setups?.map((setup) => setup.domain) ?? []),
|
||||
];
|
||||
if (domains.length) {
|
||||
this._i18n.loadBackendTranslation("title", domains);
|
||||
}
|
||||
}
|
||||
|
||||
protected render() {
|
||||
|
||||
+5
-46
@@ -16,12 +16,14 @@ import "../../../../../components/item/ha-list-item-base";
|
||||
import "../../../../../components/item/ha-list-item-button";
|
||||
import "../../../../../components/list/ha-list-base";
|
||||
import type {
|
||||
BluetoothAdapterDevice,
|
||||
BluetoothAllocationsData,
|
||||
BluetoothScannerState,
|
||||
BluetoothScannersDetails,
|
||||
HaScannerType,
|
||||
} from "../../../../../data/bluetooth";
|
||||
import {
|
||||
getBluetoothAdapters,
|
||||
isScannerStateMismatch,
|
||||
subscribeBluetoothConnectionAllocations,
|
||||
subscribeBluetoothScannerState,
|
||||
@@ -176,52 +178,11 @@ export class BluetoothAdapterInfoPage extends LitElement {
|
||||
}
|
||||
}
|
||||
|
||||
private _getBluetoothDevices = memoizeOne(
|
||||
(devices: HomeAssistant["devices"], configEntries: ConfigEntry[]) => {
|
||||
const entryMap = new Map(configEntries.map((e) => [e.entry_id, e]));
|
||||
|
||||
const enabledDevices: {
|
||||
device: DeviceRegistryEntry;
|
||||
entry: ConfigEntry;
|
||||
}[] = [];
|
||||
const disabledDevices: {
|
||||
device: DeviceRegistryEntry;
|
||||
entry: ConfigEntry;
|
||||
}[] = [];
|
||||
const matchedEntryIds = new Set<string>();
|
||||
|
||||
for (const device of Object.values(devices)) {
|
||||
const btConnection = device.connections.find(
|
||||
(c) => c[0] === "bluetooth"
|
||||
);
|
||||
if (!btConnection) {
|
||||
continue;
|
||||
}
|
||||
const entry = device.config_entries
|
||||
.map((id) => entryMap.get(id))
|
||||
.find((e) => e !== undefined);
|
||||
if (!entry) {
|
||||
continue;
|
||||
}
|
||||
matchedEntryIds.add(entry.entry_id);
|
||||
if (entry.disabled_by !== null) {
|
||||
disabledDevices.push({ device, entry });
|
||||
} else {
|
||||
enabledDevices.push({ device, entry });
|
||||
}
|
||||
}
|
||||
|
||||
const disabledEntriesWithoutDevice = configEntries.filter(
|
||||
(e) => e.disabled_by !== null && !matchedEntryIds.has(e.entry_id)
|
||||
);
|
||||
|
||||
return { enabledDevices, disabledDevices, disabledEntriesWithoutDevice };
|
||||
}
|
||||
);
|
||||
private _getBluetoothAdapters = memoizeOne(getBluetoothAdapters);
|
||||
|
||||
protected render(): TemplateResult {
|
||||
const { enabledDevices, disabledDevices, disabledEntriesWithoutDevice } =
|
||||
this._getBluetoothDevices(this.hass.devices, this._configEntries);
|
||||
this._getBluetoothAdapters(this.hass.devices, this._configEntries);
|
||||
|
||||
return html`
|
||||
<hass-subpage
|
||||
@@ -301,9 +262,7 @@ export class BluetoothAdapterInfoPage extends LitElement {
|
||||
`;
|
||||
}
|
||||
|
||||
private _renderAdaptersList(
|
||||
devices: { device: DeviceRegistryEntry; entry: ConfigEntry }[]
|
||||
) {
|
||||
private _renderAdaptersList(devices: BluetoothAdapterDevice[]) {
|
||||
if (devices.length === 0) {
|
||||
return html`<ha-list-item-base>
|
||||
<div slot="headline">
|
||||
|
||||
+122
-49
@@ -11,18 +11,24 @@ import type { UnsubscribeFunc } from "home-assistant-js-websocket";
|
||||
import type { CSSResultGroup, TemplateResult } from "lit";
|
||||
import { LitElement, css, html } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import memoizeOne from "memoize-one";
|
||||
import "../../../../../components/animation/ha-fade-in";
|
||||
import "../../../../../components/ha-alert";
|
||||
import "../../../../../components/ha-button";
|
||||
import "../../../../../components/ha-card";
|
||||
import "../../../../../components/ha-icon-next";
|
||||
import "../../../../../components/ha-svg-icon";
|
||||
import "../../../../../components/item/ha-list-item-button";
|
||||
import "../../../../../components/list/ha-list-nav";
|
||||
import "../../../../../components/skeleton/ha-skeleton";
|
||||
import "../../../../../components/skeleton/ha-skeleton-text";
|
||||
import type {
|
||||
BluetoothAllocationsData,
|
||||
BluetoothDeviceData,
|
||||
BluetoothScannerState,
|
||||
} from "../../../../../data/bluetooth";
|
||||
import {
|
||||
getBluetoothAdapters,
|
||||
isScannerStateMismatch,
|
||||
subscribeBluetoothAdvertisements,
|
||||
subscribeBluetoothConnectionAllocations,
|
||||
@@ -34,6 +40,7 @@ import "../../../../../layouts/hass-subpage";
|
||||
import { haStyle } from "../../../../../resources/styles";
|
||||
import type { HomeAssistant, Route } from "../../../../../types";
|
||||
import { brandsUrl } from "../../../../../util/brands-url";
|
||||
import { getWsErrorMessage } from "../../../../../util/ws-error";
|
||||
|
||||
@customElement("bluetooth-config-dashboard")
|
||||
export class BluetoothConfigDashboard extends LitElement {
|
||||
@@ -45,7 +52,9 @@ export class BluetoothConfigDashboard extends LitElement {
|
||||
|
||||
@property({ attribute: "is-wide", type: Boolean }) public isWide = false;
|
||||
|
||||
@state() private _configEntries: ConfigEntry[] = [];
|
||||
@state() private _configEntries?: ConfigEntry[];
|
||||
|
||||
@state() private _configEntriesError?: string;
|
||||
|
||||
@state() private _connectionAllocationData: BluetoothAllocationsData[] = [];
|
||||
|
||||
@@ -69,11 +78,17 @@ export class BluetoothConfigDashboard extends LitElement {
|
||||
}
|
||||
}
|
||||
|
||||
private async _loadConfigEntries(): Promise<void> {
|
||||
this._configEntries = await getConfigEntries(this.hass, {
|
||||
domain: "bluetooth",
|
||||
});
|
||||
}
|
||||
private _loadConfigEntries = async (): Promise<void> => {
|
||||
this._configEntriesError = undefined;
|
||||
try {
|
||||
this._configEntries = await getConfigEntries(this.hass, {
|
||||
domain: "bluetooth",
|
||||
});
|
||||
} catch (err: unknown) {
|
||||
this._configEntriesError =
|
||||
getWsErrorMessage(err) || this.hass.localize("ui.common.unknown_error");
|
||||
}
|
||||
};
|
||||
|
||||
private async _subscribeBluetoothConnectionAllocations(): Promise<void> {
|
||||
if (this._unsubConnectionAllocations) {
|
||||
@@ -131,11 +146,17 @@ export class BluetoothConfigDashboard extends LitElement {
|
||||
}
|
||||
}
|
||||
|
||||
private _getBluetoothAdapters = memoizeOne(getBluetoothAdapters);
|
||||
|
||||
protected render(): TemplateResult {
|
||||
const enabledEntries = this._configEntries.filter(
|
||||
(e) => e.disabled_by === null
|
||||
);
|
||||
const adapterCount = enabledEntries.length;
|
||||
// The device registry is null until it has loaded.
|
||||
const adapterCount =
|
||||
this._configEntries && this.hass.devices
|
||||
? this._getBluetoothAdapters(this.hass.devices, this._configEntries)
|
||||
.enabledDevices.length
|
||||
: undefined;
|
||||
const error = this._configEntriesError;
|
||||
const loading = adapterCount === undefined && !error;
|
||||
const totalSlots = this._connectionAllocationData.reduce(
|
||||
(sum, a) => sum + a.slots,
|
||||
0
|
||||
@@ -163,40 +184,67 @@ export class BluetoothConfigDashboard extends LitElement {
|
||||
back-path="/config/connectivity"
|
||||
>
|
||||
<div class="container">
|
||||
<ha-card class="content network-status">
|
||||
<div class="card-content">
|
||||
<div class="heading">
|
||||
<div class="icon ${status}">
|
||||
<ha-svg-icon .path=${statusIcon}></ha-svg-icon>
|
||||
</div>
|
||||
<div class="details">
|
||||
${this.hass.localize(
|
||||
`ui.panel.config.bluetooth.status_${status}`
|
||||
)}<br />
|
||||
<small>
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.bluetooth.connections_summary",
|
||||
{ used: usedSlots, total: totalSlots }
|
||||
)}
|
||||
</small>
|
||||
</div>
|
||||
<img
|
||||
class="logo"
|
||||
alt="Bluetooth"
|
||||
crossorigin="anonymous"
|
||||
referrerpolicy="no-referrer"
|
||||
src=${brandsUrl(
|
||||
{
|
||||
domain: "bluetooth",
|
||||
type: "icon",
|
||||
darkOptimized: this.hass.themes?.darkMode,
|
||||
},
|
||||
this.hass.auth.data.hassUrl
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</ha-card>
|
||||
${
|
||||
error
|
||||
? html`<ha-alert alert-type="error" class="content">
|
||||
${error}
|
||||
<ha-button
|
||||
slot="action"
|
||||
appearance="plain"
|
||||
@click=${this._loadConfigEntries}
|
||||
>
|
||||
${this.hass.localize("ui.common.retry")}
|
||||
</ha-button>
|
||||
</ha-alert>`
|
||||
: html`<ha-card class="content network-status">
|
||||
<div class="card-content">
|
||||
<div class="heading">
|
||||
${
|
||||
loading
|
||||
? html`<ha-fade-in .duration=${300} easing="ease-in">
|
||||
<ha-skeleton
|
||||
class="status-icon"
|
||||
role="progressbar"
|
||||
aria-label=${this.hass.localize("ui.common.loading")}
|
||||
></ha-skeleton>
|
||||
</ha-fade-in>`
|
||||
: html`<div class="icon ${status}">
|
||||
<ha-svg-icon .path=${statusIcon}></ha-svg-icon>
|
||||
</div>`
|
||||
}
|
||||
<div class="details">
|
||||
${
|
||||
loading
|
||||
? this._renderTextSkeleton()
|
||||
: this.hass.localize(
|
||||
`ui.panel.config.bluetooth.status_${status}`
|
||||
)
|
||||
}<br />
|
||||
<small>
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.bluetooth.connections_summary",
|
||||
{ used: usedSlots, total: totalSlots }
|
||||
)}
|
||||
</small>
|
||||
</div>
|
||||
<img
|
||||
class="logo"
|
||||
alt="Bluetooth"
|
||||
crossorigin="anonymous"
|
||||
referrerpolicy="no-referrer"
|
||||
src=${brandsUrl(
|
||||
{
|
||||
domain: "bluetooth",
|
||||
type: "icon",
|
||||
darkOptimized: this.hass.themes?.darkMode,
|
||||
},
|
||||
this.hass.auth.data.hassUrl
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</ha-card>`
|
||||
}
|
||||
|
||||
<ha-card class="network-card">
|
||||
<div class="card-header">
|
||||
@@ -224,10 +272,17 @@ export class BluetoothConfigDashboard extends LitElement {
|
||||
.path=${mdiAccessPoint}
|
||||
></ha-svg-icon>
|
||||
<div slot="headline">
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.bluetooth.adapters_count",
|
||||
{ count: adapterCount }
|
||||
)}
|
||||
${
|
||||
// A link needs its name, so no skeleton while loading
|
||||
adapterCount === undefined
|
||||
? this.hass.localize(
|
||||
"ui.panel.config.bluetooth.adapter_info_title"
|
||||
)
|
||||
: this.hass.localize(
|
||||
"ui.panel.config.bluetooth.adapters_count",
|
||||
{ count: adapterCount }
|
||||
)
|
||||
}
|
||||
</div>
|
||||
<ha-icon-next slot="end"></ha-icon-next>
|
||||
</ha-list-item-button>
|
||||
@@ -268,6 +323,15 @@ export class BluetoothConfigDashboard extends LitElement {
|
||||
`;
|
||||
}
|
||||
|
||||
private _renderTextSkeleton() {
|
||||
return html`<ha-fade-in .duration=${300} easing="ease-in">
|
||||
<ha-skeleton-text
|
||||
role="progressbar"
|
||||
aria-label=${this.hass.localize("ui.common.loading")}
|
||||
></ha-skeleton-text>
|
||||
</ha-fade-in>`;
|
||||
}
|
||||
|
||||
static get styles(): CSSResultGroup {
|
||||
return [
|
||||
haStyle,
|
||||
@@ -276,7 +340,9 @@ export class BluetoothConfigDashboard extends LitElement {
|
||||
padding: var(--ha-space-2) var(--ha-content-gutter) var(--ha-space-4);
|
||||
}
|
||||
|
||||
ha-card {
|
||||
ha-card,
|
||||
ha-alert {
|
||||
display: block;
|
||||
margin: 0px auto var(--ha-space-4);
|
||||
max-width: var(--ha-content-width-narrow);
|
||||
}
|
||||
@@ -326,6 +392,13 @@ export class BluetoothConfigDashboard extends LitElement {
|
||||
--icon-color: var(--primary-color);
|
||||
}
|
||||
|
||||
.network-status div.heading .status-icon {
|
||||
display: block;
|
||||
width: var(--ha-space-10);
|
||||
height: var(--ha-space-10);
|
||||
--ha-skeleton-border-radius: var(--ha-border-radius-2xl);
|
||||
}
|
||||
|
||||
.network-status div.heading .icon.online {
|
||||
--icon-color: var(--success-color);
|
||||
}
|
||||
|
||||
@@ -504,7 +504,7 @@ export class HaGridLayoutSlider extends LitElement {
|
||||
left 180ms ease-in-out,
|
||||
bottom 180ms ease-in-out;
|
||||
--handle-spacing: calc(2 * var(--handle-margin) + var(--handle-size));
|
||||
--slider-tooltip-margin: 0px;
|
||||
--slider-tooltip-margin: var(--ha-space-1);
|
||||
--slider-tooltip-range: 100%;
|
||||
--slider-tooltip-offset: 0px;
|
||||
--slider-tooltip-position: calc(
|
||||
|
||||
@@ -420,7 +420,7 @@ export class HuiCardLayoutEditor extends LitElement {
|
||||
}
|
||||
ha-grid-size-picker {
|
||||
display: block;
|
||||
margin: 16px auto;
|
||||
margin: var(--ha-space-4) auto;
|
||||
direction: ltr;
|
||||
}
|
||||
`,
|
||||
|
||||
@@ -28,12 +28,20 @@ export default <T extends Constructor<HassBaseEl>>(superClass: T) =>
|
||||
|
||||
private _startupToastKey?: string;
|
||||
|
||||
private _startupDetailsOpen = false;
|
||||
|
||||
private _disconnectedTimeout?: number;
|
||||
|
||||
protected firstUpdated(changedProps: PropertyValues<this>) {
|
||||
super.firstUpdated(changedProps);
|
||||
// Need to load in advance because when disconnected, can't dynamically load code.
|
||||
setTimeout(() => import("../managers/notification-manager"), 5000);
|
||||
this.addEventListener("dialog-closed", (ev) => {
|
||||
if (ev.detail.dialog === "dialog-startup-progress") {
|
||||
this._startupDetailsOpen = false;
|
||||
this._updateStartupProgress();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
updated(changedProperties: PropertyValues<this>) {
|
||||
@@ -135,6 +143,7 @@ export default <T extends Constructor<HassBaseEl>>(superClass: T) =>
|
||||
// Wait until the translations are available.
|
||||
if (
|
||||
!this._startupProgressVisible ||
|
||||
this._startupDetailsOpen ||
|
||||
!this.hass!.localize("ui.startup_progress.starting")
|
||||
) {
|
||||
return;
|
||||
@@ -163,13 +172,19 @@ export default <T extends Constructor<HassBaseEl>>(superClass: T) =>
|
||||
? {
|
||||
text: { translationKey: "ui.startup_progress.details" },
|
||||
icon: mdiInformationOutline,
|
||||
keepOpen: true,
|
||||
action: () => showStartupProgressDialog(this),
|
||||
action: () => this._showStartupDetails(),
|
||||
}
|
||||
: undefined,
|
||||
});
|
||||
}
|
||||
|
||||
// Toasts always show above dialogs, so the toast is hidden while the details are open.
|
||||
private _showStartupDetails() {
|
||||
this._startupDetailsOpen = true;
|
||||
this._startupToastKey = undefined;
|
||||
showStartupProgressDialog(this);
|
||||
}
|
||||
|
||||
// Keeps the subscription, so the completion toast still reflects late failures.
|
||||
private _hideStartupProgress() {
|
||||
this._startupProgressVisible = false;
|
||||
@@ -193,6 +208,9 @@ export default <T extends Constructor<HassBaseEl>>(superClass: T) =>
|
||||
);
|
||||
this._hideStartupProgress();
|
||||
this._unsubscribeBootstrapProgress();
|
||||
if (this._startupDetailsOpen) {
|
||||
return;
|
||||
}
|
||||
const issues = failed.length;
|
||||
showToast(this, {
|
||||
id: SERVER_STARTUP_TOAST_ID,
|
||||
@@ -205,7 +223,7 @@ export default <T extends Constructor<HassBaseEl>>(superClass: T) =>
|
||||
action: this.hass!.user?.is_admin
|
||||
? {
|
||||
text: this.hass!.localize("ui.notification_toast.details"),
|
||||
action: () => showStartupProgressDialog(this),
|
||||
action: () => this._showStartupDetails(),
|
||||
}
|
||||
: undefined,
|
||||
});
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import type { PropertyValues } from "lit";
|
||||
import type { HASSDomEvent } from "../common/dom/fire_event";
|
||||
import { mainWindow } from "../common/dom/get_main_window";
|
||||
import { computeDomain } from "../common/entity/compute_domain";
|
||||
import { replaceCurrentUrl } from "../common/navigate";
|
||||
import {
|
||||
createMoreInfoUrl,
|
||||
@@ -12,8 +11,6 @@ import type { MoreInfoDialogParams } from "../dialogs/more-info/ha-more-info-dia
|
||||
import type { Constructor } from "../types";
|
||||
import type { HassBaseEl } from "./hass-base-mixin";
|
||||
|
||||
const LARGE_MORE_INFO_DOMAINS = ["camera", "image"];
|
||||
|
||||
declare global {
|
||||
// for fire event
|
||||
interface HASSDomEvents {
|
||||
@@ -47,13 +44,7 @@ export default <T extends Constructor<HassBaseEl>>(superClass: T) =>
|
||||
{
|
||||
entityId: ev.detail.entityId,
|
||||
view,
|
||||
large:
|
||||
ev.detail.large ??
|
||||
(ev.detail.entityId
|
||||
? LARGE_MORE_INFO_DOMAINS.includes(
|
||||
computeDomain(ev.detail.entityId)
|
||||
)
|
||||
: false),
|
||||
large: ev.detail.large,
|
||||
data: ev.detail.data,
|
||||
returnUrl,
|
||||
},
|
||||
|
||||
@@ -2857,6 +2857,7 @@
|
||||
"in_use": "In use",
|
||||
"connecting": "Connecting",
|
||||
"not_supported_count": "Not supported by this camera ({count})",
|
||||
"enhanced_by_cloud": "Enhanced by Home Assistant Link",
|
||||
"description": {
|
||||
"web_rtc": "Real-time video with the lowest delay, usually below a second. The video takes the most direct way from the camera to your device, which can need extra network setup when you are away from home. Needed to talk to the camera.",
|
||||
"hls": "The video is sent in short pieces through Home Assistant. It works on almost every network and device, but is a few seconds behind. Used while WebRTC connects, or when WebRTC is not available.",
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import type { BluetoothScannerState } from "../../src/data/bluetooth";
|
||||
import { isScannerStateMismatch } from "../../src/data/bluetooth";
|
||||
import {
|
||||
getBluetoothAdapters,
|
||||
isScannerStateMismatch,
|
||||
} from "../../src/data/bluetooth";
|
||||
import type { ConfigEntry } from "../../src/data/config_entries";
|
||||
import type { DeviceRegistryEntry } from "../../src/data/device/device_registry";
|
||||
|
||||
const state = (
|
||||
overrides: Partial<BluetoothScannerState>
|
||||
@@ -63,3 +68,54 @@ describe("isScannerStateMismatch", () => {
|
||||
).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("getBluetoothAdapters", () => {
|
||||
const entry = (
|
||||
entry_id: string,
|
||||
overrides: Partial<ConfigEntry> = {}
|
||||
): ConfigEntry =>
|
||||
({
|
||||
entry_id,
|
||||
domain: "bluetooth",
|
||||
source: "user",
|
||||
disabled_by: null,
|
||||
...overrides,
|
||||
}) as ConfigEntry;
|
||||
|
||||
const device = (
|
||||
id: string,
|
||||
configEntries: string[],
|
||||
connections: [string, string][] = [["bluetooth", id]]
|
||||
): DeviceRegistryEntry =>
|
||||
({
|
||||
id,
|
||||
config_entries: configEntries,
|
||||
connections,
|
||||
}) as DeviceRegistryEntry;
|
||||
|
||||
it("only counts entries with a Bluetooth device as adapters", () => {
|
||||
const entries = [
|
||||
entry("proxy"),
|
||||
entry("ignored", { source: "ignore" }),
|
||||
entry("removed"),
|
||||
entry("disabled", { disabled_by: "user" }),
|
||||
entry("disabled-without-device", { disabled_by: "user" }),
|
||||
];
|
||||
const devices = {
|
||||
proxy: device("proxy", ["esphome", "proxy"]),
|
||||
disabled: device("disabled", ["disabled"]),
|
||||
"no-bluetooth": device("no-bluetooth", ["proxy"], [["mac", "x"]]),
|
||||
other: device("other", ["other-integration"]),
|
||||
};
|
||||
|
||||
const result = getBluetoothAdapters(devices, entries);
|
||||
|
||||
expect(result.enabledDevices.map((a) => a.device.id)).toEqual(["proxy"]);
|
||||
expect(result.disabledDevices.map((a) => a.device.id)).toEqual([
|
||||
"disabled",
|
||||
]);
|
||||
expect(result.disabledEntriesWithoutDevice.map((e) => e.entry_id)).toEqual([
|
||||
"disabled-without-device",
|
||||
]);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,66 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import type { CoverEntity } from "../../src/data/cover";
|
||||
import { CoverEntityFeature, coverCurrentValue } from "../../src/data/cover";
|
||||
|
||||
const TILT_FEATURES =
|
||||
CoverEntityFeature.OPEN_TILT +
|
||||
CoverEntityFeature.CLOSE_TILT +
|
||||
CoverEntityFeature.STOP_TILT;
|
||||
|
||||
const cover = (
|
||||
state: string,
|
||||
supportedFeatures: number,
|
||||
attributes: Partial<CoverEntity["attributes"]> = {}
|
||||
): CoverEntity =>
|
||||
({
|
||||
entity_id: "cover.blind",
|
||||
state,
|
||||
attributes: { supported_features: supportedFeatures, ...attributes },
|
||||
}) as CoverEntity;
|
||||
|
||||
describe("coverCurrentValue", () => {
|
||||
it("uses the state for the tilt of a tilt-only cover without a tilt position", () => {
|
||||
expect(coverCurrentValue(cover("closed", TILT_FEATURES), "tilt")).toBe(0);
|
||||
expect(coverCurrentValue(cover("opening", TILT_FEATURES), "tilt")).toBe(0);
|
||||
expect(coverCurrentValue(cover("open", TILT_FEATURES), "tilt")).toBe(100);
|
||||
expect(coverCurrentValue(cover("closing", TILT_FEATURES), "tilt")).toBe(
|
||||
100
|
||||
);
|
||||
});
|
||||
|
||||
it("has no tilt when the state of a tilt-only cover is unknown", () => {
|
||||
expect(
|
||||
coverCurrentValue(cover("unknown", TILT_FEATURES), "tilt")
|
||||
).toBeUndefined();
|
||||
expect(
|
||||
coverCurrentValue(cover("unavailable", TILT_FEATURES), "tilt")
|
||||
).toBeUndefined();
|
||||
});
|
||||
|
||||
it("prefers the reported tilt position", () => {
|
||||
expect(
|
||||
coverCurrentValue(
|
||||
cover("closed", TILT_FEATURES, { current_tilt_position: 30 }),
|
||||
"tilt"
|
||||
)
|
||||
).toBe(30);
|
||||
});
|
||||
|
||||
it("does not use the state for the tilt when the cover also moves up and down", () => {
|
||||
expect(
|
||||
coverCurrentValue(
|
||||
cover("closed", TILT_FEATURES + CoverEntityFeature.OPEN),
|
||||
"tilt"
|
||||
)
|
||||
).toBeUndefined();
|
||||
});
|
||||
|
||||
it("does not use the state for the tilt when the cover can set its tilt position", () => {
|
||||
expect(
|
||||
coverCurrentValue(
|
||||
cover("closed", TILT_FEATURES + CoverEntityFeature.SET_TILT_POSITION),
|
||||
"tilt"
|
||||
)
|
||||
).toBeUndefined();
|
||||
});
|
||||
});
|
||||
@@ -284,13 +284,6 @@ describe("browseLinkFromUrl", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("filters on no integration category for an empty one", () => {
|
||||
expect(
|
||||
browseLinkFromUrl("?integration_category=")?.filters
|
||||
.integration_category ?? []
|
||||
).toEqual([]);
|
||||
});
|
||||
|
||||
it("keeps what was picked for a link that says nothing about browsing", () => {
|
||||
expect(
|
||||
browseLinkFromUrl("?owner=hacs&repository=integration")
|
||||
@@ -299,13 +292,6 @@ describe("browseLinkFromUrl", () => {
|
||||
});
|
||||
|
||||
describe("filtersOfTab", () => {
|
||||
it("keeps the integration category on every tab", () => {
|
||||
expect(
|
||||
filtersOfTab({ integration_category: ["energy"] }, "installed")
|
||||
.integration_category
|
||||
).toEqual(["energy"]);
|
||||
});
|
||||
|
||||
it("only offers statuses something installed can have on the installed tab", () => {
|
||||
expect(statusesOfTab("installed")).toEqual([
|
||||
"pending-restart",
|
||||
|
||||
Reference in new issue
Block a user