mirror of
https://github.com/home-assistant/frontend.git
synced 2026-11-26 14:49:00 +00:00
Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
00312420d8 | ||
|
|
f2116b61fc | ||
|
|
2e872965f6 | ||
|
|
cbf745f38a |
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",
|
||||
|
||||
@@ -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;
|
||||
|
||||
+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 {
|
||||
|
||||
@@ -149,8 +149,6 @@ 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;
|
||||
@@ -217,7 +215,6 @@ export class MoreInfoDialog extends DirtyStateProviderMixin<
|
||||
this._detailsYamlMode = false;
|
||||
|
||||
this.large = params.large ?? false;
|
||||
this._fill = false;
|
||||
this._open = true;
|
||||
this._loadEntityRegistryEntry();
|
||||
}
|
||||
@@ -701,13 +698,7 @@ export class MoreInfoDialog extends DirtyStateProviderMixin<
|
||||
return html`
|
||||
<ha-adaptive-dialog
|
||||
.open=${this._open}
|
||||
.width=${
|
||||
this._fill
|
||||
? "full"
|
||||
: this.large || mediaAspectRatio
|
||||
? "large"
|
||||
: "medium"
|
||||
}
|
||||
.width=${this.large || mediaAspectRatio ? "large" : "medium"}
|
||||
class=${classMap({
|
||||
camera: domain === "camera",
|
||||
image: domain === "image",
|
||||
@@ -751,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
|
||||
@@ -1168,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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
`,
|
||||
|
||||
@@ -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"];
|
||||
|
||||
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,
|
||||
},
|
||||
|
||||
@@ -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