Skip to content

Commit

Permalink
Update add switch entity dialog with options for regulator locks and …
Browse files Browse the repository at this point in the history
…key locks (#26)
  • Loading branch information
alengwenus authored Oct 29, 2024
1 parent 76d7b6d commit e664bcc
Show file tree
Hide file tree
Showing 5 changed files with 103 additions and 19 deletions.
18 changes: 9 additions & 9 deletions src/dialogs/lcn-config-binary-sensor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ export class LCNConfigBinarySensorElement extends LitElement {
];
}

private get _setpoints(): ConfigItem[] {
const setpoint: string = this.lcn.localize("setpoint");
private get _regulators(): ConfigItem[] {
const regulator: string = this.lcn.localize("regulator");
return [
{ name: setpoint + " 1", value: "R1VARSETPOINT" },
{ name: setpoint + " 2", value: "R2VARSETPOINT" },
{ name: regulator + " 1", value: "R1VARSETPOINT" },
{ name: regulator + " 2", value: "R2VARSETPOINT" },
];
}

Expand Down Expand Up @@ -95,17 +95,17 @@ export class LCNConfigBinarySensorElement extends LitElement {
private get _sourceTypes(): ConfigItemCollection[] {
return [
{
name: this.lcn.localize("binary-sensor-type-binsensors"),
name: this.lcn.localize("binsensors"),
value: this._binsensorPorts,
id: "binsensors",
},
{
name: this.lcn.localize("binary-sensor-type-setpoint-locks"),
value: this._setpoints,
id: "setpoint-locks",
name: this.lcn.localize("regulator-locks"),
value: this._regulators,
id: "regulator-locks",
},
{
name: this.lcn.localize("binary-sensor-type-keys-locks"),
name: this.lcn.localize("key-locks"),
value: this._keys,
id: "key-locks",
},
Expand Down
71 changes: 70 additions & 1 deletion src/dialogs/lcn-config-switch.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import "@ha/components/ha-list-item";
import "@ha/components/ha-select";
import type { HaSelect } from "@ha/components/ha-select";
import "@ha/components/ha-textfield";
import { css, html, LitElement, CSSResultGroup, nothing } from "lit";
import { customElement, property, query, state } from "lit/decorators";
import type { HomeAssistant, ValueChangedEvent } from "@ha/types";
Expand Down Expand Up @@ -60,10 +61,55 @@ export class LCNConfigSwitchElement extends LitElement {
];
}

private get _regulators(): ConfigItem[] {
const regulator: string = this.lcn.localize("regulator");
return [
{ name: regulator + " 1", value: "R1VARSETPOINT" },
{ name: regulator + " 2", value: "R2VARSETPOINT" },
];
}

private _keys: ConfigItem[] = [
{ name: "A1", value: "A1" },
{ name: "A2", value: "A2" },
{ name: "A3", value: "A3" },
{ name: "A4", value: "A4" },
{ name: "A5", value: "A5" },
{ name: "A6", value: "A6" },
{ name: "A7", value: "A7" },
{ name: "A8", value: "A8" },
{ name: "B1", value: "B1" },
{ name: "B2", value: "B2" },
{ name: "B3", value: "B3" },
{ name: "B4", value: "B4" },
{ name: "B5", value: "B5" },
{ name: "B6", value: "B6" },
{ name: "B7", value: "B7" },
{ name: "B8", value: "B8" },
{ name: "C1", value: "C1" },
{ name: "C2", value: "C2" },
{ name: "C3", value: "C3" },
{ name: "C4", value: "C4" },
{ name: "C5", value: "C5" },
{ name: "C6", value: "C6" },
{ name: "C7", value: "C7" },
{ name: "C8", value: "C8" },
{ name: "D1", value: "D1" },
{ name: "D2", value: "D2" },
{ name: "D3", value: "D3" },
{ name: "D4", value: "D4" },
{ name: "D5", value: "D5" },
{ name: "D6", value: "D6" },
{ name: "D7", value: "D7" },
{ name: "D8", value: "D8" },
];

private get _portTypes(): ConfigItemCollection[] {
return [
{ name: this.lcn.localize("output"), value: this._outputPorts, id: "output" },
{ name: this.lcn.localize("relay"), value: this._relayPorts, id: "relay" },
{ name: this.lcn.localize("regulator"), value: this._regulators, id: "regulator-locks" },
{ name: this.lcn.localize("key"), value: this._keys, id: "key-locks" },
];
}

Expand Down Expand Up @@ -98,9 +144,27 @@ export class LCNConfigSwitchElement extends LitElement {
></ha-radio>
</ha-formfield>
<ha-formfield label=${this.lcn.localize("regulator-lock")}>
<ha-radio
name="port"
value="regulator-locks"
.checked=${this._portType.id === "regulator-locks"}
@change=${this._portTypeChanged}
></ha-radio>
</ha-formfield>
<ha-formfield label=${this.lcn.localize("key-lock")}>
<ha-radio
name="port"
value="key-locks"
.checked=${this._portType.id === "key-locks"}
@change=${this._portTypeChanged}
></ha-radio>
</ha-formfield>
<ha-select
id="port-select"
.label=${this.lcn.localize("port")}
.label=${this._portType.name}
.value=${this._port.value}
fixedMenuPosition
@selected=${this._portChanged}
Expand Down Expand Up @@ -136,6 +200,11 @@ export class LCNConfigSwitchElement extends LitElement {
#port-type {
margin-top: 16px;
}
.lock-time {
display: grid;
grid-template-columns: 1fr 1fr;
column-gap: 4px;
}
ha-select {
display: block;
margin-bottom: 8px;
Expand Down
1 change: 0 additions & 1 deletion src/dialogs/lcn-create-entity-dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ export class CreateEntityDialog extends LitElement {
id="name-input"
label=${this.lcn.localize("name")}
type="string"
maxLength="20"
@input=${this._nameChanged}
></ha-textfield>
Expand Down
16 changes: 12 additions & 4 deletions src/localize/languages/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@
"variables": "Variablen",
"setpoint": "Sollwert",
"setpoints": "Sollwerte",
"regulator": "Regler",
"regulator-lock": "Reglersperrung",
"key": "Taste",
"key-lock": "Tastensperrung",
"motor": "Motor",
"reverse-delay": "Umkehrverzögerung",
"output": "Ausgang",
Expand All @@ -59,10 +63,14 @@
"unit-volts": "Volt",
"unit-milliamperes": "Milliampere",
"unit-angle": "Winkel",

"binary-sensor-type-binsensors": "Binärsensoren",
"binary-sensor-type-setpoint-locks": "Sperrung Sollwerte",
"binary-sensor-type-keys-locks": "Sperrung Tasten",
"unit-seconds": "Sekunden",
"unit-minutes": "Minuten",
"unit-hours": "Stunden",
"unit-days": "Tage",

"binsensors": "Binärsensoren",
"regulator-locks": "Sperrung Regler",
"key-locks": "Sperrung Tasten",

"more-help": "mehr Hilfe...",
"delete-selected": "Ausgewählte entfernen",
Expand Down
16 changes: 12 additions & 4 deletions src/localize/languages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@
"variables": "Variables",
"setpoint": "Setpoint",
"setpoints": "Setpoints",
"regulator": "Regulator",
"regulator-lock": "Regulator lock",
"key": "Key",
"key-lock": "Key lock",
"motor": "Motor",
"reverse-delay": "Reverse delay",
"output": "Output",
Expand Down Expand Up @@ -60,10 +64,14 @@
"unit-volts": "Volts",
"unit-milliamperes": "Milliamperes",
"unit-angle": "Angle",

"binary-sensor-type-binsensors": "Binary sensors",
"binary-sensor-type-setpoint-locks": "Lock state setpoints",
"binary-sensor-type-keys-locks": "Lock state keys",
"unit-seconds": "Seconds",
"unit-minutes": "Minutes",
"unit-hours": "Hours",
"unit-days": "Days",

"binsensors": "Binary sensors",
"regulator-locks": "Lock state regulators",
"key-locks": "Lock state keys",

"more-help": "more help...",
"delete-selected": "Delete selected",
Expand Down

0 comments on commit e664bcc

Please sign in to comment.