Skip to content

Commit

Permalink
20240829.0 (#21836)
Browse files Browse the repository at this point in the history
  • Loading branch information
bramkragten authored Aug 29, 2024
2 parents 8349e47 + 05a27b9 commit 22de449
Show file tree
Hide file tree
Showing 60 changed files with 267 additions and 199 deletions.
42 changes: 23 additions & 19 deletions gallery/src/pages/automation/editor-condition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,70 +11,74 @@ import { mockHassioSupervisor } from "../../../../demo/src/stubs/hassio_supervis
import type { ConditionWithShorthand } from "../../../../src/data/automation";
import "../../../../src/panels/config/automation/condition/ha-automation-condition";
import { HaDeviceCondition } from "../../../../src/panels/config/automation/condition/types/ha-automation-condition-device";
import { HaLogicalCondition } from "../../../../src/panels/config/automation/condition/types/ha-automation-condition-logical";
import HaNumericStateCondition from "../../../../src/panels/config/automation/condition/types/ha-automation-condition-numeric_state";
import { HaStateCondition } from "../../../../src/panels/config/automation/condition/types/ha-automation-condition-state";
import { HaSunCondition } from "../../../../src/panels/config/automation/condition/types/ha-automation-condition-sun";
import { HaTemplateCondition } from "../../../../src/panels/config/automation/condition/types/ha-automation-condition-template";
import { HaTimeCondition } from "../../../../src/panels/config/automation/condition/types/ha-automation-condition-time";
import { HaTriggerCondition } from "../../../../src/panels/config/automation/condition/types/ha-automation-condition-trigger";
import { HaZoneCondition } from "../../../../src/panels/config/automation/condition/types/ha-automation-condition-zone";
import { HaAndCondition } from "../../../../src/panels/config/automation/condition/types/ha-automation-condition-and";
import { HaOrCondition } from "../../../../src/panels/config/automation/condition/types/ha-automation-condition-or";
import { HaNotCondition } from "../../../../src/panels/config/automation/condition/types/ha-automation-condition-not";

const SCHEMAS: { name: string; conditions: ConditionWithShorthand[] }[] = [
{
name: "State",
conditions: [{ condition: "state", ...HaStateCondition.defaultConfig }],
conditions: [{ ...HaStateCondition.defaultConfig }],
},
{
name: "Numeric State",
conditions: [
{ condition: "numeric_state", ...HaNumericStateCondition.defaultConfig },
],
conditions: [{ ...HaNumericStateCondition.defaultConfig }],
},
{
name: "Sun",
conditions: [{ condition: "sun", ...HaSunCondition.defaultConfig }],
conditions: [{ ...HaSunCondition.defaultConfig }],
},
{
name: "Zone",
conditions: [{ condition: "zone", ...HaZoneCondition.defaultConfig }],
conditions: [{ ...HaZoneCondition.defaultConfig }],
},
{
name: "Time",
conditions: [{ condition: "time", ...HaTimeCondition.defaultConfig }],
conditions: [{ ...HaTimeCondition.defaultConfig }],
},
{
name: "Template",
conditions: [
{ condition: "template", ...HaTemplateCondition.defaultConfig },
],
conditions: [{ ...HaTemplateCondition.defaultConfig }],
},
{
name: "Device",
conditions: [{ condition: "device", ...HaDeviceCondition.defaultConfig }],
conditions: [{ ...HaDeviceCondition.defaultConfig }],
},
{
name: "And",
conditions: [{ condition: "and", ...HaLogicalCondition.defaultConfig }],
conditions: [{ ...HaAndCondition.defaultConfig }],
},
{
name: "Or",
conditions: [{ condition: "or", ...HaLogicalCondition.defaultConfig }],
conditions: [{ ...HaOrCondition.defaultConfig }],
},
{
name: "Not",
conditions: [{ condition: "not", ...HaLogicalCondition.defaultConfig }],
conditions: [{ ...HaNotCondition.defaultConfig }],
},
{
name: "Trigger",
conditions: [{ condition: "trigger", ...HaTriggerCondition.defaultConfig }],
conditions: [{ ...HaTriggerCondition.defaultConfig }],
},
{
name: "Shorthand",
conditions: [
{ and: HaLogicalCondition.defaultConfig.conditions },
{ or: HaLogicalCondition.defaultConfig.conditions },
{ not: HaLogicalCondition.defaultConfig.conditions },
{
...HaAndCondition.defaultConfig,
},
{
...HaOrCondition.defaultConfig,
},
{
...HaNotCondition.defaultConfig,
},
],
},
];
Expand Down
37 changes: 15 additions & 22 deletions gallery/src/pages/automation/editor-trigger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,93 +30,86 @@ import { HaConversationTrigger } from "../../../../src/panels/config/automation/
const SCHEMAS: { name: string; triggers: Trigger[] }[] = [
{
name: "State",
triggers: [{ platform: "state", ...HaStateTrigger.defaultConfig }],
triggers: [{ ...HaStateTrigger.defaultConfig }],
},

{
name: "MQTT",
triggers: [{ platform: "mqtt", ...HaMQTTTrigger.defaultConfig }],
triggers: [{ ...HaMQTTTrigger.defaultConfig }],
},

{
name: "GeoLocation",
triggers: [
{ platform: "geo_location", ...HaGeolocationTrigger.defaultConfig },
],
triggers: [{ ...HaGeolocationTrigger.defaultConfig }],
},

{
name: "Home Assistant",
triggers: [{ platform: "homeassistant", ...HaHassTrigger.defaultConfig }],
triggers: [{ ...HaHassTrigger.defaultConfig }],
},

{
name: "Numeric State",
triggers: [
{ platform: "numeric_state", ...HaNumericStateTrigger.defaultConfig },
],
triggers: [{ ...HaNumericStateTrigger.defaultConfig }],
},

{
name: "Sun",
triggers: [{ platform: "sun", ...HaSunTrigger.defaultConfig }],
triggers: [{ ...HaSunTrigger.defaultConfig }],
},

{
name: "Time Pattern",
triggers: [
{ platform: "time_pattern", ...HaTimePatternTrigger.defaultConfig },
],
triggers: [{ ...HaTimePatternTrigger.defaultConfig }],
},

{
name: "Webhook",
triggers: [{ platform: "webhook", ...HaWebhookTrigger.defaultConfig }],
triggers: [{ ...HaWebhookTrigger.defaultConfig }],
},

{
name: "Persistent Notification",
triggers: [
{
platform: "persistent_notification",
...HaPersistentNotificationTrigger.defaultConfig,
},
],
},

{
name: "Zone",
triggers: [{ platform: "zone", ...HaZoneTrigger.defaultConfig }],
triggers: [{ ...HaZoneTrigger.defaultConfig }],
},

{
name: "Tag",
triggers: [{ platform: "tag", ...HaTagTrigger.defaultConfig }],
triggers: [{ ...HaTagTrigger.defaultConfig }],
},

{
name: "Time",
triggers: [{ platform: "time", ...HaTimeTrigger.defaultConfig }],
triggers: [{ ...HaTimeTrigger.defaultConfig }],
},

{
name: "Template",
triggers: [{ platform: "template", ...HaTemplateTrigger.defaultConfig }],
triggers: [{ ...HaTemplateTrigger.defaultConfig }],
},

{
name: "Event",
triggers: [{ platform: "event", ...HaEventTrigger.defaultConfig }],
triggers: [{ ...HaEventTrigger.defaultConfig }],
},

{
name: "Device Trigger",
triggers: [{ platform: "device", ...HaDeviceTrigger.defaultConfig }],
triggers: [{ ...HaDeviceTrigger.defaultConfig }],
},
{
name: "Sentence",
triggers: [
{ platform: "conversation", ...HaConversationTrigger.defaultConfig },
{ ...HaConversationTrigger.defaultConfig },
{
platform: "conversation",
command: ["Turn on the lights", "Turn the lights on"],
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "home-assistant-frontend"
version = "20240828.0"
version = "20240829.0"
license = {text = "Apache-2.0"}
description = "The Home Assistant frontend"
readme = "README.md"
Expand Down
10 changes: 5 additions & 5 deletions src/components/ha-formfield.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ export class HaFormfield extends FormfieldBase {

return html` <div class="mdc-form-field ${classMap(classes)}">
<slot></slot>
<label class="mdc-label" @click=${this._labelClick}
><slot name="label">${this.label}</slot></label
>
<label class="mdc-label" @click=${this._labelClick}>
<slot name="label">${this.label}</slot>
</label>
</div>`;
}

Expand Down Expand Up @@ -57,13 +57,13 @@ export class HaFormfield extends FormfieldBase {
}
.mdc-form-field {
align-items: var(--ha-formfield-align-items, center);
gap: 4px;
}
.mdc-form-field > label {
direction: var(--direction);
margin-inline-start: 0;
margin-inline-end: auto;
padding-inline-start: 4px;
padding-inline-end: 0;
padding: 0;
}
:host([disabled]) label {
color: var(--disabled-text-color);
Expand Down
24 changes: 19 additions & 5 deletions src/components/ha-selector/ha-selector-boolean.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { css, CSSResultGroup, html, LitElement } from "lit";
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
import { customElement, property } from "lit/decorators";
import { fireEvent } from "../../common/dom/fire_event";
import { HomeAssistant } from "../../types";
Expand Down Expand Up @@ -28,10 +28,13 @@ export class HaBooleanSelector extends LitElement {
@change=${this._handleChange}
.disabled=${this.disabled}
></ha-switch>
<span slot="label">
<p class="primary">${this.label}</p>
${this.helper
? html`<p class="secondary">${this.helper}</p>`
: nothing}
</span>
</ha-formfield>
${this.helper
? html`<ha-input-helper-text>${this.helper}</ha-input-helper-text>`
: ""}
`;
}

Expand All @@ -47,10 +50,21 @@ export class HaBooleanSelector extends LitElement {
return css`
ha-formfield {
display: flex;
height: 56px;
min-height: 56px;
align-items: center;
--mdc-typography-body2-font-size: 1em;
}
p {
margin: 0;
}
.secondary {
direction: var(--direction);
padding-top: 4px;
box-sizing: border-box;
color: var(--secondary-text-color);
font-size: 0.875rem;
font-weight: var(--mdc-typography-body2-font-weight, 400);
}
`;
}
}
Expand Down
21 changes: 15 additions & 6 deletions src/components/ha-selector/ha-selector-number.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
import { css, CSSResultGroup, html, LitElement, PropertyValues } from "lit";
import {
css,
CSSResultGroup,
html,
LitElement,
nothing,
PropertyValues,
} from "lit";
import { customElement, property } from "lit/decorators";
import { classMap } from "lit/directives/class-map";
import { fireEvent } from "../../common/dom/fire_event";
Expand Down Expand Up @@ -60,12 +67,10 @@ export class HaNumberSelector extends LitElement {
}

return html`
${this.label ? html`${this.label}${this.required ? "*" : ""}` : nothing}
<div class="input">
${!isBox
? html`
${this.label
? html`${this.label}${this.required ? "*" : ""}`
: ""}
<ha-slider
labeled
.min=${this.selector.number!.min}
Expand All @@ -75,10 +80,11 @@ export class HaNumberSelector extends LitElement {
.disabled=${this.disabled}
.required=${this.required}
@change=${this._handleSliderChange}
.ticks=${this.selector.number?.slider_ticks}
>
</ha-slider>
`
: ""}
: nothing}
<ha-textfield
.inputMode=${this.selector.number?.step === "any" ||
(this.selector.number?.step ?? 1) % 1 !== 0
Expand All @@ -105,7 +111,7 @@ export class HaNumberSelector extends LitElement {
</div>
${!isBox && this.helper
? html`<ha-input-helper-text>${this.helper}</ha-input-helper-text>`
: ""}
: nothing}
`;
}

Expand Down Expand Up @@ -141,6 +147,9 @@ export class HaNumberSelector extends LitElement {
}
ha-slider {
flex: 1;
margin-right: 16px;
margin-inline-end: 16px;
margin-inline-start: 0;
}
ha-textfield {
--ha-textfield-input-width: 40px;
Expand Down
1 change: 1 addition & 0 deletions src/components/ha-slider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export class HaSlider extends MdSlider {
--md-sys-color-on-surface: var(--primary-text-color);
--md-slider-handle-width: 14px;
--md-slider-handle-height: 14px;
--md-slider-state-layer-size: 24px;
min-width: 100px;
min-inline-size: 100px;
width: 200px;
Expand Down
4 changes: 3 additions & 1 deletion src/data/lovelace/config/view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ export interface LovelaceBaseViewConfig {
visible?: boolean | ShowViewConfig[];
subview?: boolean;
back_path?: string;
max_columns?: number; // Only used for section view, it should move to a section view config type when the views will have dedicated editor.
// Only used for section view, it should move to a section view config type when the views will have dedicated editor.
max_columns?: number;
dense_section_placement?: boolean;
}

export interface LovelaceViewConfig extends LovelaceBaseViewConfig {
Expand Down
1 change: 1 addition & 0 deletions src/data/selector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ export interface NumberSelector {
step?: number | "any";
mode?: "box" | "slider";
unit_of_measurement?: string;
slider_ticks?: boolean;
} | null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export class HaChooseAction extends LitElement implements ActionElement {
this._unsubMql = undefined;
}

public static get defaultConfig() {
public static get defaultConfig(): ChooseAction {
return { choose: [{ conditions: [], sequence: [] }] };
}

Expand Down
Loading

0 comments on commit 22de449

Please sign in to comment.