From b969144f5083f21fc5e56e394c6c2e149901063b Mon Sep 17 00:00:00 2001 From: Steve Repsher Date: Fri, 19 Jan 2024 03:43:00 -0500 Subject: [PATCH] Initialize more boolean properties (#19452) --- src/components/ha-area-picker.ts | 2 +- src/components/ha-areas-picker.ts | 2 +- src/components/ha-attribute-value.ts | 3 +- src/components/ha-combo-box.ts | 3 +- src/components/ha-control-circular-slider.ts | 67 +++++++------------ src/components/ha-control-select-menu.ts | 4 +- src/components/ha-control-switch.ts | 12 ++-- src/components/ha-multi-textfield.ts | 2 +- src/components/ha-service-control.ts | 2 +- src/components/trace/hat-graph-branch.ts | 2 +- src/components/trace/hat-graph-node.ts | 4 +- src/components/trace/hat-graph-spacer.ts | 2 +- src/onboarding/onboarding-welcome-link.ts | 2 +- src/panels/calendar/ha-panel-calendar.ts | 3 +- .../automation/blueprint-automation-editor.ts | 2 +- .../core/ha-config-system-navigation.ts | 3 +- .../config/dashboard/ha-config-dashboard.ts | 3 +- .../config/script/blueprint-script-editor.ts | 2 +- src/panels/history/ha-panel-history.ts | 2 +- src/panels/logbook/ha-panel-logbook.ts | 2 +- .../conditions/ha-card-conditions-editor.ts | 2 +- .../media-browser/ha-bar-media-player.ts | 3 +- .../media-browser/ha-panel-media-browser.ts | 3 +- .../ha-state-control-climate-humidity.ts | 4 +- .../ha-state-control-climate-temperature.ts | 6 +- .../ha-state-control-humidifier-humidity.ts | 6 +- ...-state-control-water_heater-temperature.ts | 4 +- 27 files changed, 61 insertions(+), 91 deletions(-) diff --git a/src/components/ha-area-picker.ts b/src/components/ha-area-picker.ts index 8e84cb77fc..fd68a8eb4b 100644 --- a/src/components/ha-area-picker.ts +++ b/src/components/ha-area-picker.ts @@ -54,7 +54,7 @@ export class HaAreaPicker extends LitElement { @property() public placeholder?: string; @property({ type: Boolean, attribute: "no-add" }) - public noAdd?: boolean; + public noAdd = false; /** * Show only areas with entities from specific domains. diff --git a/src/components/ha-areas-picker.ts b/src/components/ha-areas-picker.ts index 1d648ee5fd..0d36f8e3fe 100644 --- a/src/components/ha-areas-picker.ts +++ b/src/components/ha-areas-picker.ts @@ -20,7 +20,7 @@ export class HaAreasPicker extends SubscribeMixin(LitElement) { @property() public placeholder?: string; @property({ type: Boolean, attribute: "no-add" }) - public noAdd?: boolean; + public noAdd = false; /** * Show only areas with entities from specific domains. diff --git a/src/components/ha-attribute-value.ts b/src/components/ha-attribute-value.ts index 387b2612b0..a56bd7d399 100644 --- a/src/components/ha-attribute-value.ts +++ b/src/components/ha-attribute-value.ts @@ -13,8 +13,7 @@ class HaAttributeValue extends LitElement { @property() public attribute!: string; - @property({ type: Boolean, attribute: "hide-unit" }) - public hideUnit?: boolean; + @property({ type: Boolean, attribute: "hide-unit" }) public hideUnit = false; protected render() { if (!this.stateObj) { diff --git a/src/components/ha-combo-box.ts b/src/components/ha-combo-box.ts index fa241e69d8..5dd9d2a211 100644 --- a/src/components/ha-combo-box.ts +++ b/src/components/ha-combo-box.ts @@ -101,8 +101,7 @@ export class HaComboBox extends LitElement { @property({ type: Boolean }) public required = false; - @property({ type: Boolean, reflect: true, attribute: "opened" }) - public opened?: boolean; + @property({ type: Boolean, reflect: true }) public opened = false; @query("vaadin-combo-box-light", true) private _comboBox!: ComboBoxLight; diff --git a/src/components/ha-control-circular-slider.ts b/src/components/ha-control-circular-slider.ts index eb475aacb5..9ba2a3d8b7 100644 --- a/src/components/ha-control-circular-slider.ts +++ b/src/components/ha-control-circular-slider.ts @@ -71,68 +71,49 @@ export type ControlCircularSliderMode = "start" | "end" | "full"; @customElement("ha-control-circular-slider") export class HaControlCircularSlider extends LitElement { - @property({ type: Boolean, reflect: true }) - public disabled = false; + @property({ type: Boolean, reflect: true }) public disabled = false; - @property({ type: Boolean, reflect: true }) - public readonly = false; + @property({ type: Boolean, reflect: true }) public readonly = false; - @property({ type: Boolean }) - public dual?: boolean; + @property({ type: Boolean }) public dual = false; - @property({ type: String }) - public mode?: ControlCircularSliderMode; + @property({ type: String }) public mode?: ControlCircularSliderMode; - @property({ type: Boolean }) - public inactive?: boolean; + @property({ type: Boolean }) public inactive = false; - @property({ type: String }) - public label?: string; + @property({ type: String }) public label?: string; - @property({ type: String, attribute: "low-label" }) - public lowLabel?: string; + @property({ type: String, attribute: "low-label" }) public lowLabel?: string; @property({ type: String, attribute: "high-label" }) public highLabel?: string; - @property({ type: Number }) - public value?: number; + @property({ type: Number }) public value?: number; - @property({ type: Number }) - public low?: number; + @property({ type: Number }) public low?: number; - @property({ type: Number }) - public high?: number; + @property({ type: Number }) public high?: number; - @property({ type: Number }) - public current?: number; + @property({ type: Number }) public current?: number; - @property({ type: Number }) - public step = 1; + @property({ type: Number }) public step = 1; - @property({ type: Number }) - public min = 0; + @property({ type: Number }) public min = 0; - @property({ type: Number }) - public max = 100; + @property({ type: Number }) public max = 100; @property({ type: Boolean, attribute: "prevent-interaction-on-scroll" }) - public preventInteractionOnScroll?: boolean; + public preventInteractionOnScroll = false; - @state() - public _localValue?: number = this.value; + @state() public _localValue?: number = this.value; - @state() - public _localLow?: number = this.low; + @state() public _localLow?: number = this.low; - @state() - public _localHigh?: number = this.high; + @state() public _localHigh?: number = this.high; - @state() - public _activeSlider?: ActiveSlider; + @state() public _activeSlider?: ActiveSlider; - @state() - public _lastSlider?: ActiveSlider; + @state() public _lastSlider?: ActiveSlider; private _valueToPercentage(value: number) { return ( @@ -618,11 +599,11 @@ export class HaControlCircularSlider extends LitElement { targetCircle ? svg` - ; diff --git a/src/components/ha-control-switch.ts b/src/components/ha-control-switch.ts index ef2968b69a..2626b2ea20 100644 --- a/src/components/ha-control-switch.ts +++ b/src/components/ha-control-switch.ts @@ -19,17 +19,13 @@ import "./ha-svg-icon"; @customElement("ha-control-switch") export class HaControlSwitch extends LitElement { - @property({ type: Boolean, reflect: true }) - public disabled = false; + @property({ type: Boolean, reflect: true }) public disabled = false; - @property({ type: Boolean }) - public vertical = false; + @property({ type: Boolean }) public vertical = false; - @property({ type: Boolean }) - public reversed = false; + @property({ type: Boolean }) public reversed = false; - @property({ type: Boolean, reflect: true }) - public checked?: boolean; + @property({ type: Boolean, reflect: true }) public checked = false; // SVG icon path (if you need a non SVG icon instead, use the provided on icon slot to pass an in) @property({ type: String }) pathOn?: string; diff --git a/src/components/ha-multi-textfield.ts b/src/components/ha-multi-textfield.ts index 471a3e7bcb..e4305b377d 100644 --- a/src/components/ha-multi-textfield.ts +++ b/src/components/ha-multi-textfield.ts @@ -32,7 +32,7 @@ class HaMultiTextField extends LitElement { @property() public removeLabel?: string; @property({ attribute: "item-index", type: Boolean }) - public itemIndex?: boolean; + public itemIndex = false; protected render() { return html` diff --git a/src/components/ha-service-control.ts b/src/components/ha-service-control.ts index dde29966e9..12b5c8bd5a 100644 --- a/src/components/ha-service-control.ts +++ b/src/components/ha-service-control.ts @@ -88,7 +88,7 @@ export class HaServiceControl extends ReorderModeMixin(LitElement) { @property({ type: Boolean }) public disabled = false; - @property({ reflect: true, type: Boolean }) public narrow!: boolean; + @property({ type: Boolean, reflect: true }) public narrow = false; @property({ type: Boolean }) public showAdvanced = false; diff --git a/src/components/trace/hat-graph-branch.ts b/src/components/trace/hat-graph-branch.ts index a1d8a94e70..373cfb58d5 100644 --- a/src/components/trace/hat-graph-branch.ts +++ b/src/components/trace/hat-graph-branch.ts @@ -17,7 +17,7 @@ interface BranchConfig { */ @customElement("hat-graph-branch") export class HatGraphBranch extends LitElement { - @property({ reflect: true, type: Boolean }) disabled?: boolean; + @property({ type: Boolean, reflect: true }) disabled = false; @property({ type: Boolean }) selected = false; diff --git a/src/components/trace/hat-graph-node.ts b/src/components/trace/hat-graph-node.ts index c55b03e20e..931f0a6524 100644 --- a/src/components/trace/hat-graph-node.ts +++ b/src/components/trace/hat-graph-node.ts @@ -17,11 +17,11 @@ import { NODE_SIZE, SPACING } from "./hat-graph-const"; export class HatGraphNode extends LitElement { @property() iconPath?: string; - @property({ reflect: true, type: Boolean }) disabled?: boolean; + @property({ type: Boolean, reflect: true }) public disabled = false; @property({ reflect: true, type: Boolean }) notEnabled = false; - @property({ reflect: true, type: Boolean }) graphStart?: boolean; + @property({ reflect: true, type: Boolean }) graphStart = false; @property({ type: Boolean, attribute: "nofocus" }) noFocus = false; diff --git a/src/components/trace/hat-graph-spacer.ts b/src/components/trace/hat-graph-spacer.ts index 37c79a18bb..32a91622e8 100644 --- a/src/components/trace/hat-graph-spacer.ts +++ b/src/components/trace/hat-graph-spacer.ts @@ -8,7 +8,7 @@ import { SPACING, NODE_SIZE } from "./hat-graph-const"; */ @customElement("hat-graph-spacer") export class HatGraphSpacer extends LitElement { - @property({ reflect: true, type: Boolean }) disabled?: boolean; + @property({ reflect: true, type: Boolean }) public disabled = false; render() { return html` diff --git a/src/onboarding/onboarding-welcome-link.ts b/src/onboarding/onboarding-welcome-link.ts index 54810e5ed1..d1d7972f15 100644 --- a/src/onboarding/onboarding-welcome-link.ts +++ b/src/onboarding/onboarding-welcome-link.ts @@ -18,7 +18,7 @@ class OnboardingWelcomeLink extends LitElement { @property() public iconPath!: string; - @property({ attribute: true, type: Boolean }) public noninteractive?: boolean; + @property({ type: Boolean }) public noninteractive = false; @queryAsync("mwc-ripple") private _ripple!: Promise; diff --git a/src/panels/calendar/ha-panel-calendar.ts b/src/panels/calendar/ha-panel-calendar.ts index 0e4547fc07..1c37d7bedd 100644 --- a/src/panels/calendar/ha-panel-calendar.ts +++ b/src/panels/calendar/ha-panel-calendar.ts @@ -42,8 +42,7 @@ import "./ha-full-calendar"; class PanelCalendar extends LitElement { @property({ attribute: false }) public hass!: HomeAssistant; - @property({ type: Boolean, reflect: true }) - public narrow!: boolean; + @property({ type: Boolean, reflect: true }) public narrow = false; @property({ type: Boolean, reflect: true }) public mobile = false; diff --git a/src/panels/config/automation/blueprint-automation-editor.ts b/src/panels/config/automation/blueprint-automation-editor.ts index 06bf397334..635e5ada3e 100644 --- a/src/panels/config/automation/blueprint-automation-editor.ts +++ b/src/panels/config/automation/blueprint-automation-editor.ts @@ -30,7 +30,7 @@ export class HaBlueprintAutomationEditor extends ReorderModeMixin(LitElement) { @property({ type: Boolean }) public disabled = false; - @property({ reflect: true, type: Boolean }) public narrow!: boolean; + @property({ reflect: true, type: Boolean }) public narrow = false; @property() public config!: BlueprintAutomationConfig; diff --git a/src/panels/config/core/ha-config-system-navigation.ts b/src/panels/config/core/ha-config-system-navigation.ts index db1cdf6227..9f46770667 100644 --- a/src/panels/config/core/ha-config-system-navigation.ts +++ b/src/panels/config/core/ha-config-system-navigation.ts @@ -29,8 +29,7 @@ import { configSections } from "../ha-panel-config"; class HaConfigSystemNavigation extends LitElement { @property({ attribute: false }) public hass!: HomeAssistant; - @property({ type: Boolean, reflect: true }) - public narrow!: boolean; + @property({ type: Boolean, reflect: true }) public narrow = false; @property({ type: Boolean }) public isWide = false; diff --git a/src/panels/config/dashboard/ha-config-dashboard.ts b/src/panels/config/dashboard/ha-config-dashboard.ts index f1f1e5ba7e..8bcb950c9c 100644 --- a/src/panels/config/dashboard/ha-config-dashboard.ts +++ b/src/panels/config/dashboard/ha-config-dashboard.ts @@ -114,8 +114,7 @@ const randomTip = (hass: HomeAssistant, narrow: boolean) => { class HaConfigDashboard extends SubscribeMixin(LitElement) { @property({ attribute: false }) public hass!: HomeAssistant; - @property({ type: Boolean, reflect: true }) - public narrow!: boolean; + @property({ type: Boolean, reflect: true }) public narrow = false; @property({ type: Boolean }) public isWide = false; diff --git a/src/panels/config/script/blueprint-script-editor.ts b/src/panels/config/script/blueprint-script-editor.ts index 4c3a8c17dc..a2dfd7f40d 100644 --- a/src/panels/config/script/blueprint-script-editor.ts +++ b/src/panels/config/script/blueprint-script-editor.ts @@ -26,7 +26,7 @@ export class HaBlueprintScriptEditor extends ReorderModeMixin(LitElement) { @property({ type: Boolean }) public isWide = false; - @property({ reflect: true, type: Boolean }) public narrow!: boolean; + @property({ reflect: true, type: Boolean }) public narrow = false; @property({ type: Boolean }) public disabled = false; diff --git a/src/panels/history/ha-panel-history.ts b/src/panels/history/ha-panel-history.ts index 67b481b71b..fbed2990a9 100644 --- a/src/panels/history/ha-panel-history.ts +++ b/src/panels/history/ha-panel-history.ts @@ -58,7 +58,7 @@ import { fileDownload } from "../../util/file_download"; class HaPanelHistory extends SubscribeMixin(LitElement) { @property({ attribute: false }) hass!: HomeAssistant; - @property({ reflect: true, type: Boolean }) narrow!: boolean; + @property({ reflect: true, type: Boolean }) public narrow = false; @property({ reflect: true, type: Boolean }) rtl = false; diff --git a/src/panels/logbook/ha-panel-logbook.ts b/src/panels/logbook/ha-panel-logbook.ts index 567e28595a..cd9b6ed16e 100644 --- a/src/panels/logbook/ha-panel-logbook.ts +++ b/src/panels/logbook/ha-panel-logbook.ts @@ -23,7 +23,7 @@ import "./ha-logbook"; export class HaPanelLogbook extends LitElement { @property({ attribute: false }) public hass!: HomeAssistant; - @property({ reflect: true, type: Boolean }) narrow!: boolean; + @property({ type: Boolean, reflect: true }) public narrow = false; @state() _time: { range: [Date, Date] }; diff --git a/src/panels/lovelace/editor/conditions/ha-card-conditions-editor.ts b/src/panels/lovelace/editor/conditions/ha-card-conditions-editor.ts index b0f5eaf851..125d715bb9 100644 --- a/src/panels/lovelace/editor/conditions/ha-card-conditions-editor.ts +++ b/src/panels/lovelace/editor/conditions/ha-card-conditions-editor.ts @@ -46,7 +46,7 @@ export class HaCardConditionsEditor extends LitElement { | LegacyCondition )[]; - @property({ attribute: true, type: Boolean }) public nested?: boolean; + @property({ type: Boolean }) public nested = false; private _focusLastConditionOnChange = false; diff --git a/src/panels/media-browser/ha-bar-media-player.ts b/src/panels/media-browser/ha-bar-media-player.ts index ee8f238f24..f9cbb28689 100644 --- a/src/panels/media-browser/ha-bar-media-player.ts +++ b/src/panels/media-browser/ha-bar-media-player.ts @@ -70,8 +70,7 @@ export class BarMediaPlayer extends SubscribeMixin(LitElement) { @property({ attribute: false }) public entityId!: string; - @property({ type: Boolean, reflect: true }) - public narrow!: boolean; + @property({ type: Boolean, reflect: true }) public narrow = false; @query("mwc-linear-progress") private _progressBar?: LinearProgress; diff --git a/src/panels/media-browser/ha-panel-media-browser.ts b/src/panels/media-browser/ha-panel-media-browser.ts index eb77c02eed..8713bed2a4 100644 --- a/src/panels/media-browser/ha-panel-media-browser.ts +++ b/src/panels/media-browser/ha-panel-media-browser.ts @@ -65,8 +65,7 @@ const createMediaPanelUrl = (entityId: string, items: MediaPlayerItemId[]) => { class PanelMediaBrowser extends LitElement { @property({ attribute: false }) public hass!: HomeAssistant; - @property({ type: Boolean, reflect: true }) - public narrow!: boolean; + @property({ type: Boolean, reflect: true }) public narrow = false; @property({ attribute: false }) public route!: Route; diff --git a/src/state-control/climate/ha-state-control-climate-humidity.ts b/src/state-control/climate/ha-state-control-climate-humidity.ts index 9918db1044..e8830eea59 100644 --- a/src/state-control/climate/ha-state-control-climate-humidity.ts +++ b/src/state-control/climate/ha-state-control-climate-humidity.ts @@ -27,10 +27,10 @@ export class HaStateControlClimateHumidity extends LitElement { @property({ attribute: false }) public stateObj!: ClimateEntity; @property({ attribute: "show-current", type: Boolean }) - public showCurrent?: boolean; + public showCurrent = false; @property({ type: Boolean, attribute: "prevent-interaction-on-scroll" }) - public preventInteractionOnScroll?: boolean; + public preventInteractionOnScroll = false; @state() private _targetHumidity?: number; diff --git a/src/state-control/climate/ha-state-control-climate-temperature.ts b/src/state-control/climate/ha-state-control-climate-temperature.ts index 7565871603..e449704b1c 100644 --- a/src/state-control/climate/ha-state-control-climate-temperature.ts +++ b/src/state-control/climate/ha-state-control-climate-temperature.ts @@ -55,13 +55,13 @@ export class HaStateControlClimateTemperature extends LitElement { @property({ attribute: false }) public stateObj!: ClimateEntity; @property({ attribute: "show-secondary", type: Boolean }) - public showSecondary?: boolean; + public showSecondary = false; @property({ attribute: "use-current-as-primary", type: Boolean }) - public showCurrentAsPrimary?: boolean; + public showCurrentAsPrimary = false; @property({ type: Boolean, attribute: "prevent-interaction-on-scroll" }) - public preventInteractionOnScroll?: boolean; + public preventInteractionOnScroll = false; @state() private _targetTemperature: Partial> = {}; diff --git a/src/state-control/humidifier/ha-state-control-humidifier-humidity.ts b/src/state-control/humidifier/ha-state-control-humidifier-humidity.ts index 459e8d6117..351fc92c19 100644 --- a/src/state-control/humidifier/ha-state-control-humidifier-humidity.ts +++ b/src/state-control/humidifier/ha-state-control-humidifier-humidity.ts @@ -30,13 +30,13 @@ export class HaStateControlHumidifierHumidity extends LitElement { @property({ attribute: false }) public stateObj!: HumidifierEntity; @property({ attribute: "show-secondary", type: Boolean }) - public showSecondary?: boolean; + public showSecondary = false; @property({ attribute: "use-current-as-primary", type: Boolean }) - public showCurrentAsPrimary?: boolean; + public showCurrentAsPrimary = false; @property({ type: Boolean, attribute: "prevent-interaction-on-scroll" }) - public preventInteractionOnScroll?: boolean; + public preventInteractionOnScroll = false; @state() private _targetHumidity?: number; diff --git a/src/state-control/water_heater/ha-state-control-water_heater-temperature.ts b/src/state-control/water_heater/ha-state-control-water_heater-temperature.ts index 4e52499618..53a41cd1fe 100644 --- a/src/state-control/water_heater/ha-state-control-water_heater-temperature.ts +++ b/src/state-control/water_heater/ha-state-control-water_heater-temperature.ts @@ -30,10 +30,10 @@ export class HaStateControlWaterHeaterTemperature extends LitElement { @property({ attribute: false }) public stateObj!: WaterHeaterEntity; @property({ attribute: "show-current", type: Boolean }) - public showCurrent?: boolean; + public showCurrent = false; @property({ type: Boolean, attribute: "prevent-interaction-on-scroll" }) - public preventInteractionOnScroll?: boolean; + public preventInteractionOnScroll = false; @state() private _targetTemperature?: number;