Config UI: add heating support (#22177)

This commit is contained in:
Michael Geers 2025-07-07 21:36:32 +02:00 • committed by GitHub
parent b6ff1cad92
commit f3b60644e8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
60 changed files with 1399 additions and 486 deletions

View file

@ -21,7 +21,7 @@
/>
<YamlEntry
v-if="values.type === 'custom'"
v-if="showYamlInput"
v-model="values.yaml"
type="charger"
:error-line="test.errorLine"
@ -112,8 +112,16 @@ import {
type ModbusCapability,
applyDefaultsFromTemplate,
createDeviceUtils,
customChargerName,
} from "./DeviceModal";
import defaultYaml from "./defaultYaml/charger.yaml?raw";
import customChargerYaml from "./defaultYaml/customCharger.yaml?raw";
import customHeaterYaml from "./defaultYaml/customHeater.yaml?raw";
import heatpumpYaml from "./defaultYaml/heatpump.yaml?raw";
import switchsocketHeaterYaml from "./defaultYaml/switchsocketHeater.yaml?raw";
import switchsocketChargerYaml from "./defaultYaml/switchsocketCharger.yaml?raw";
import sgreadyYaml from "./defaultYaml/sgready.yaml?raw";
import sgreadyBoostYaml from "./defaultYaml/sgreadyBoost.yaml?raw";
import { LOADPOINT_TYPE } from "@/types/evcc";
const initialValues = { type: ConfigType.Template };
const device = createDeviceUtils("charger");
@ -157,6 +165,7 @@ export default defineComponent({
props: {
id: Number,
name: String,
loadpointType: { type: String as () => LOADPOINT_TYPE | null, default: null },
fade: String,
isSponsor: Boolean,
},
@ -177,35 +186,58 @@ export default defineComponent({
computed: {
modalTitle() {
if (this.isNew) {
return this.$t(`config.charger.titleAdd`);
return this.$t(`config.charger.titleAdd.${this.loadpointType}`);
}
return this.$t(`config.charger.titleEdit`);
return this.$t(`config.charger.titleEdit.${this.loadpointType}`);
},
modalSize() {
return this.values.type === ConfigType.Custom ? "xl" : undefined;
return this.showYamlInput ? "xl" : undefined;
},
templateOptions() {
return [
{
const result = [];
if (this.isHeating) {
result.push({
label: "generic",
options: [
...this.products.filter((p) => p.group === "heatinggeneric"),
...[
ConfigType.Custom,
ConfigType.SgReadyBoost,
ConfigType.SgReady,
ConfigType.Heatpump,
ConfigType.SwitchSocket,
].map((type) =>
customTemplateOption(this.$t(customChargerName(type, true)), type)
),
],
});
result.push({
label: "heatingdevices",
options: this.products.filter((p) => p.group === "heating"),
});
} else {
result.push({
label: "generic",
options: [
...this.products.filter((p) => p.group === "generic"),
customTemplateOption(this.$t("config.general.customOption")),
...[ConfigType.Custom, ConfigType.SwitchSocket].map((type) =>
customTemplateOption(this.$t(customChargerName(type, false)), type)
),
],
},
{
});
result.push({
label: "chargers",
options: this.products.filter((p) => !p.group),
},
{
label: "switchsockets",
options: this.products.filter((p) => p.group === "switchsockets"),
},
{
label: "heatingdevices",
options: this.products.filter((p) => p.group === "heating"),
},
];
});
}
result.push({
label: "switchsockets",
options: this.products.filter((p) => p.group === "switchsockets"),
});
return result;
},
templateParams() {
const params = this.template?.Params || [];
@ -233,7 +265,7 @@ export default defineComponent({
this.templateParams.some((p) => p.Name === "connector") &&
this.templateParams.some((p) => p.Name === "stationid");
if (isOcpp) {
return `ws://${window.location.hostname}:8887`;
return `ws://${window.location.hostname}:8887/${this.values["stationid"] || ""}`;
}
return null;
},
@ -250,7 +282,11 @@ export default defineComponent({
return this.template?.Requirements?.Description;
},
productName() {
return this.values.deviceProduct || this.templateName || "";
return (
this.values.deviceProduct ||
this.templateName ||
this.$t(customChargerName(this.values.type, this.isHeating))
);
},
sponsorTokenRequired() {
const requirements = this.template?.Requirements as Requirements | undefined;
@ -269,11 +305,17 @@ export default defineComponent({
isNew() {
return this.id === undefined;
},
isHeating() {
return this.loadpointType === LOADPOINT_TYPE.HEATING;
},
isDeletable() {
return !this.isNew;
},
showActions() {
return this.templateName || this.values.type === ConfigType.Custom;
return this.templateName || this.showYamlInput;
},
showYamlInput() {
return this.isYamlInput(this.values.type);
},
},
watch: {
@ -311,12 +353,29 @@ export default defineComponent({
// TODO: adjust GET response to match POST/PUT formats
this.values.type = charger.type;
this.values.deviceProduct = charger.deviceProduct;
applyDefaultsFromTemplate(this.template, this.values);
this.applyDefaults();
this.templateName = this.values.template;
} catch (e) {
console.error(e);
}
},
applyDefaults() {
applyDefaultsFromTemplate(this.template, this.values);
if (this.isHeating) {
// enable heating and integrated device params if exist
const hasParam = (name: string) =>
this.template?.Params.some((p) => p.Name === name);
["heating", "integrateddevice"].forEach((param) => {
if (hasParam(param) && this.values[param] === undefined) {
this.values[param] = true;
}
});
// default heater icon
if (hasParam("icon") && this.values["icon"] === undefined) {
this.values["icon"] = "heater";
}
}
},
async loadProducts() {
if (!this.isModalVisible) {
return;
@ -329,11 +388,11 @@ export default defineComponent({
},
async loadTemplate() {
this.template = null;
if (!this.templateName || this.templateName === ConfigType.Custom) return;
if (!this.templateName || this.isYamlInput(this.templateName as ConfigType)) return;
this.loadingTemplate = true;
try {
this.template = await device.loadTemplate(this.templateName, this.$i18n?.locale);
applyDefaultsFromTemplate(this.template, this.values);
this.applyDefaults();
} catch (e) {
console.error(e);
}
@ -407,13 +466,38 @@ export default defineComponent({
this.isModalVisible = false;
},
templateChanged(e: Event) {
const value = (e.target as HTMLSelectElement).value;
const value = (e.target as HTMLSelectElement).value as ConfigType;
this.reset();
if (value === ConfigType.Custom) {
this.values.type = ConfigType.Custom;
this.values.yaml = defaultYaml;
if (this.isYamlInput(value)) {
this.values.type = value;
this.values.yaml = this.defaultYaml(value);
}
},
defaultYaml(type: ConfigType) {
switch (type) {
case ConfigType.Custom:
return this.isHeating ? customHeaterYaml : customChargerYaml;
case ConfigType.Heatpump:
return heatpumpYaml;
case ConfigType.SwitchSocket:
return this.isHeating ? switchsocketHeaterYaml : switchsocketChargerYaml;
case ConfigType.SgReady:
return sgreadyYaml;
case ConfigType.SgReadyBoost:
return sgreadyBoostYaml;
default: // template
return "";
}
},
isYamlInput(type: ConfigType) {
return [
ConfigType.Custom,
ConfigType.Heatpump,
ConfigType.SwitchSocket,
ConfigType.SgReady,
ConfigType.SgReadyBoost,
].includes(type);
},
},
});
</script>

View file

@ -1,5 +1,5 @@
<template>
<li class="root round-box" :class="{ 'round-box--error': error }">
<div class="root round-box" :class="{ 'round-box--error': error }">
<div class="d-flex align-items-center mb-2">
<div class="icon me-2">
<slot name="icon" />
@ -27,7 +27,7 @@
</div>
<hr class="my-3 divide" />
<slot name="tags" />
</li>
</div>
</template>
<script>

View file

@ -86,7 +86,7 @@ export default defineComponent({
},
});
export function customTemplateOption(name: string) {
return { template: "custom", name };
export function customTemplateOption(name: string, template = "custom") {
return { name, template };
}
</script>

View file

@ -57,6 +57,10 @@ export const timeout = 15000;
export enum ConfigType {
Template = "template",
Custom = "custom",
Heatpump = "heatpump",
SwitchSocket = "switchsocket",
SgReady = "sgready",
SgReadyBoost = "sgready-boost",
}
export function applyDefaultsFromTemplate(template: Template | null, values: DeviceValues) {
@ -68,6 +72,18 @@ export function applyDefaultsFromTemplate(template: Template | null, values: Dev
});
}
export function customChargerName(type: ConfigType, isHeating: boolean) {
if (!type) {
return "config.general.customOption";
}
const prefix = "config.charger.type.";
const suffix = isHeating ? ".heating" : ".charging";
if (type === ConfigType.Custom) {
return `${prefix}custom${suffix}`;
}
return `${prefix}${type}`;
}
export function createDeviceUtils(deviceType: DeviceType) {
function test(id: number | undefined, data: any) {
let url = `config/test/${deviceType}`;

View file

@ -29,6 +29,8 @@ import formatter, { POWER_UNIT } from "@/mixins/formatter";
const NO_TRUNCATE = ["phasePowers", "phaseVoltages", "phaseCurrents"];
const HIDDEN_TAGS = ["icon", "heating", "integratedDevice"];
export default {
name: "DeviceTags",
mixins: [formatter],
@ -37,11 +39,11 @@ export default {
},
computed: {
entries() {
return Object.entries(this.tags).map(
([name, { value, error, warning, muted, options }]) => {
return Object.entries(this.tags)
.filter(([name]) => !HIDDEN_TAGS.includes(name))
.map(([name, { value, error, warning, muted, options }]) => {
return { name, value, error, warning, muted, options };
}
);
});
},
},
methods: {

View file

@ -9,11 +9,27 @@
@opened="onOpened"
@close="onClose"
>
<form ref="form" class="container mx-0 px-0" @submit.prevent="isNew ? create() : update()">
<div v-if="!loadpointType" class="d-flex flex-column gap-4">
<NewDeviceButton
v-for="t in typeChoices"
:key="t"
:title="$t(`config.loadpoint.option.${t}`)"
class="addButton"
@click="selectType(t)"
/>
</div>
<form
v-else
ref="form"
class="container mx-0 px-0"
@submit.prevent="isNew ? create() : update()"
>
<FormRow
id="loadpointParamTitle"
:label="$t('config.loadpoint.titleLabel')"
:example="$t('config.loadpoint.titleExample')"
:example="
loadpointType ? $t(`config.loadpoint.titleExample.${loadpointType}`) : undefined
"
>
<PropertyField
id="loadpointParamTitle"
@ -26,8 +42,8 @@
<FormRow
v-if="charger || !isNew"
id="loadpointParamCharger"
:label="$t('config.loadpoint.chargerLabel')"
:error="!charger ? $t('config.loadpoint.chargerError') : null"
:label="$t(`config.loadpoint.chargerLabel.${loadpointType}`)"
:error="!charger ? $t(`config.loadpoint.chargerError.${loadpointType}`) : undefined"
>
<div class="d-flex">
<PropertyField
@ -56,7 +72,7 @@
:disabled="values.title?.length === 0"
@click.prevent="editCharger"
>
{{ $t("config.loadpoint.addCharger") }}
{{ addChargerLabel }}
</button>
</div>
<div v-if="charger || !isNew">
@ -95,7 +111,7 @@
tabindex="0"
@click="editMeter"
>
{{ $t("config.loadpoint.addMeter") }}
{{ $t(`config.loadpoint.addMeter`) }}
</button>
</p>
</div>
@ -108,8 +124,8 @@
:label="$t('config.loadpoint.defaultModeLabel')"
:help="
values.defaultMode === ''
? $t('config.loadpoint.defaultModeHelpKeep')
: $t('config.loadpoint.defaultModeHelp')
? $t(`config.loadpoint.defaultModeHelpKeep`)
: $t(`config.loadpoint.defaultModeHelp.${loadpointType}`)
"
>
<PropertyField
@ -129,7 +145,6 @@
</FormRow>
<FormRow
v-show="showAll"
id="loadpointSolarMode"
:label="$t('config.loadpoint.solarBehaviorLabel')"
:help="
@ -281,7 +296,6 @@
</div>
<FormRow
v-show="showAll"
v-if="showPriority"
id="loadpointParamPriority"
:label="$t('config.loadpoint.priorityLabel')"
@ -298,7 +312,7 @@
/>
</FormRow>
<h6 v-show="showAll">
<h6>
{{ $t("config.loadpoint.electricalTitle") }}
<small class="text-muted">{{
$t("config.loadpoint.electricalSubtitle")
@ -334,7 +348,11 @@
id="loadpointMinCurrent"
:label="$t('config.loadpoint.minCurrentLabel')"
class="col-sm-6 mb-sm-0"
:help="values.minCurrent < 6 ? $t('config.loadpoint.minCurrentHelp') : null"
:help="
values.minCurrent < 6
? $t('config.loadpoint.minCurrentHelp')
: undefined
"
>
<PropertyField
id="loadpointMinCurrent"
@ -354,7 +372,7 @@
:help="
values.maxCurrent < values.minCurrent
? $t('config.loadpoint.maxCurrentHelp')
: null
: undefined
"
>
<PropertyField
@ -371,7 +389,6 @@
<template v-if="!chargerIsSinglePhase">
<FormRow
v-show="showAll"
v-if="chargerSupports1p3p"
id="loadpointParamPhases"
:label="$t('config.loadpoint.phasesAutomatic')"
@ -380,7 +397,6 @@
</FormRow>
<FormRow
v-else
v-show="showAll"
id="loadpointParamPhases"
:label="$t('config.loadpoint.phasesLabel')"
:help="$t('config.loadpoint.phasesHelp')"
@ -389,10 +405,7 @@
id="loadpointParamPhases"
v-model="values.phasesConfigured"
class="w-100"
:options="[
{ value: 1, name: $t('config.loadpoint.phases1p') },
{ value: 3, name: $t('config.loadpoint.phases3p') },
]"
:options="phasesOptions"
transparent
equal-width
/>
@ -400,7 +413,6 @@
</template>
<FormRow
v-show="showAll"
v-if="showCircuit"
id="loadpointParamCircuit"
:label="$t('config.loadpoint.circuitLabel')"
@ -416,107 +428,102 @@
/>
</FormRow>
<h6 v-show="showAll">{{ $t("config.loadpoint.vehiclesTitle") }}</h6>
<div v-if="!chargerIsIntegratedDevice">
<h6>{{ $t("config.loadpoint.vehiclesTitle") }}</h6>
<div v-if="vehicleOptions.length">
<FormRow
id="loadpointParamVehicle"
:label="$t('config.loadpoint.vehicleLabel')"
:help="
values.vehicle
? $t('config.loadpoint.vehicleHelpDefault')
: $t('config.loadpoint.vehicleHelpAutoDetection')
"
>
<PropertyField
<div v-if="vehicleOptions.length">
<FormRow
id="loadpointParamVehicle"
v-model="values.vehicle"
type="Choice"
class="me-2"
:choice="allVehicleOptions"
required
/>
</FormRow>
:label="$t('config.loadpoint.vehicleLabel')"
:help="
values.vehicle
? $t('config.loadpoint.vehicleHelpDefault')
: $t('config.loadpoint.vehicleHelpAutoDetection')
"
>
<PropertyField
id="loadpointParamVehicle"
v-model="values.vehicle"
type="Choice"
class="me-2"
:choice="allVehicleOptions"
required
/>
</FormRow>
<FormRow
v-show="showAll"
id="loadpointPollMode"
:label="$t('config.loadpoint.pollModeLabel')"
:help="
values.soc.poll.mode === 'charging'
? $t('config.loadpoint.pollModeChargingHelp')
: values.soc.poll.mode === 'connected'
? $t('config.loadpoint.pollModeConnectedHelp')
: values.soc.poll.mode === 'always'
? $t('config.loadpoint.pollModeAlwaysHelp')
: null
"
>
<SelectGroup
<FormRow
id="loadpointPollMode"
v-model="values.soc.poll.mode"
class="w-100"
:options="[
{
value: 'charging',
name: $t('config.loadpoint.pollModeCharging'),
},
{
value: 'connected',
name: $t('config.loadpoint.pollModeConnected'),
},
{ value: 'always', name: $t('config.loadpoint.pollModeAlways') },
]"
transparent
/>
</FormRow>
<FormRow
v-show="showAll"
v-if="values.soc.poll.mode !== 'charging'"
id="loadpointPollInterval"
class="ms-3 mb-5"
:label="$t('config.loadpoint.pollIntervalLabel')"
:help="$t('config.loadpoint.pollIntervalHelp')"
:danger="$t('config.loadpoint.pollIntervalDanger')"
>
<PropertyField
:label="$t('config.loadpoint.pollModeLabel')"
:help="
values.soc.poll.mode === 'charging'
? $t('config.loadpoint.pollModeChargingHelp')
: values.soc.poll.mode === 'connected'
? $t('config.loadpoint.pollModeConnectedHelp')
: values.soc.poll.mode === 'always'
? $t('config.loadpoint.pollModeAlwaysHelp')
: undefined
"
>
<SelectGroup
id="loadpointPollMode"
v-model="values.soc.poll.mode"
class="w-100"
:options="[
{
value: 'charging',
name: $t('config.loadpoint.pollModeCharging'),
},
{
value: 'connected',
name: $t('config.loadpoint.pollModeConnected'),
},
{
value: 'always',
name: $t('config.loadpoint.pollModeAlways'),
},
]"
transparent
/>
</FormRow>
<FormRow
v-if="values.soc.poll.mode !== 'charging'"
id="loadpointPollInterval"
v-model="values.soc.poll.interval"
type="Duration"
unit="minute"
size="w-25 w-min-200"
class="me-2"
required
/>
</FormRow>
class="ms-3 mb-5"
:label="$t('config.loadpoint.pollIntervalLabel')"
:help="$t('config.loadpoint.pollIntervalHelp')"
:danger="$t('config.loadpoint.pollIntervalDanger')"
>
<PropertyField
id="loadpointPollInterval"
v-model="values.soc.poll.interval"
type="Duration"
unit="minute"
size="w-25 w-min-200"
class="me-2"
required
/>
</FormRow>
<div v-show="showAll" class="d-flex mb-4">
<input
id="loadpointEstimate"
v-model="values.soc.estimate"
class="form-check-input"
type="checkbox"
/>
<label class="form-check-label ms-2" for="loadpointEstimate">
{{ $t("config.loadpoint.estimateLabel") }}
</label>
<div>
<div class="d-flex mb-4">
<input
id="loadpointEstimate"
v-model="values.soc.estimate"
class="form-check-input"
type="checkbox"
/>
<label class="form-check-label ms-2" for="loadpointEstimate">
{{ $t("config.loadpoint.estimateLabel") }}
</label>
</div>
</div>
</div>
<div v-else>
<p class="text-muted">{{ $t("config.loadpoint.noVehicles") }}</p>
</div>
</div>
<div v-else v-show="showAll">
<p class="text-muted">{{ $t("config.loadpoint.noVehicles") }}</p>
</div>
</div>
<button
v-if="!showAll && values.charger"
class="btn btn-link btn-sm text-gray px-0 border-0 d-flex align-items-center mb-2"
type="button"
tabindex="0"
@click="showAllSelected = true"
>
{{ $t("config.loadpoint.showAllSettings") }}
</button>
<div v-if="values.charger" class="mt-5 mb-4 d-flex justify-content-between">
<button
v-if="isDeletable"
@ -548,7 +555,7 @@
</GenericModal>
</template>
<script>
<script lang="ts">
import FormRow from "./FormRow.vue";
import PropertyField from "./PropertyField.vue";
import SelectGroup from "../Helper/SelectGroup.vue";
@ -558,10 +565,14 @@ import deepClone from "@/utils/deepClone";
import deepEqual from "@/utils/deepEqual";
import formatter, { POWER_UNIT } from "@/mixins/formatter";
import EditIcon from "../MaterialIcon/Edit.vue";
import NewDeviceButton from "./NewDeviceButton.vue";
import { type ConfigType, handleError, customChargerName } from "./DeviceModal";
import { LOADPOINT_TYPE } from "@/types/evcc";
const nsPerMin = 60 * 1e9;
const defaultValues = {
id: undefined,
title: "",
phasesConfigured: 3,
minCurrent: 6,
@ -587,57 +598,79 @@ const defaultThresholds = {
disable: { delay: 3 * nsPerMin, threshold: 0 },
};
type LoadpointValues = typeof defaultValues;
type Charger = {
name: string;
deviceProduct: string;
type: ConfigType;
config: { template: string };
};
type Meter = {
name: string;
deviceProduct: string;
config: { template: string };
};
type Circuit = {
name: string;
config: { title: string };
};
export default {
name: "LoadpointModal",
components: { FormRow, PropertyField, GenericModal, SelectGroup, EditIcon },
components: { FormRow, PropertyField, GenericModal, SelectGroup, EditIcon, NewDeviceButton },
mixins: [formatter],
props: {
id: Number,
name: String,
vehicleOptions: { type: Array, default: () => [] },
loadpointCount: Number,
loadpointCount: { type: Number, default: 0 },
fade: String,
chargers: { type: Array, default: () => [] },
chargers: { type: Array as () => Charger[], default: () => [] },
chargerValues: { type: Object, default: () => {} },
meters: { type: Array, default: () => [] },
circuits: { type: Array, default: () => [] },
meters: { type: Array as () => Meter[], default: () => [] },
circuits: { type: Array as () => Circuit[], default: () => [] },
},
emits: ["updated", "openMeterModal", "openChargerModal", "opened"],
data() {
return {
isModalVisible: false,
saving: false,
selectedType: null,
values: deepClone(defaultValues),
selectedType: null as LOADPOINT_TYPE | null,
values: deepClone(defaultValues) as LoadpointValues,
chargerPower: "11kw",
solarMode: "default",
tab: "solar",
showAllSelected: false,
powerUnit: POWER_UNIT,
};
},
computed: {
modalTitle() {
if (this.isNew) {
return this.$t(`config.loadpoint.titleAdd`);
return this.$t(`config.loadpoint.titleAdd.${this.loadpointType || "unknown"}`);
}
return this.$t(`config.loadpoint.titleEdit`);
return this.$t(`config.loadpoint.titleEdit.${this.loadpointType || "unknown"}`);
},
isNew() {
return this.id === undefined;
},
showAll() {
return !this.isNew || this.showAllSelected;
},
charger() {
return this.chargers.find((c) => c.name === this.values.charger);
},
chargerType() {
if (!this.charger) {
return null;
}
return this.chargerIsHeating ? LOADPOINT_TYPE.HEATING : LOADPOINT_TYPE.CHARGING;
},
chargerTitle() {
if (!this.charger) return "";
const title =
this.charger.deviceProduct ||
this.charger.config?.template ||
this.$t("config.general.customOption");
this.$t(customChargerName(this.charger.type, this.chargerIsHeating));
return `${title} [${this.values.charger}]`;
},
chargerStatus() {
@ -652,6 +685,12 @@ export default {
chargerIsSinglePhase() {
return this.chargerStatus.singlePhase?.value || false;
},
chargerIsIntegratedDevice() {
return this.chargerStatus.integratedDevice?.value || false;
},
chargerIsHeating() {
return this.chargerStatus.heating?.value === true;
},
meterTitle() {
const name = this.values.meter;
if (!name) return "";
@ -669,12 +708,21 @@ export default {
return this.isNew ? this.loadpointCount > 0 : this.loadpointCount > 1;
},
priorityOptions() {
const result = Array.from({ length: 11 }, (_, i) => ({ key: i, name: `${i}` }));
const result = Array.from({ length: 11 }, (_, i) => ({ key: i, name: `${i}` })) as {
key?: number;
name: string;
}[];
result[0].name = "0 (default)";
result[0].key = undefined;
result[10].name = "10 (highest)";
return result;
},
phasesOptions() {
return [
{ value: "1", name: this.$t("config.loadpoint.phases1p") },
{ value: "3", name: this.$t("config.loadpoint.phases3p") },
];
},
showCircuit() {
return this.circuits.length > 0;
},
@ -692,6 +740,18 @@ export default {
...this.vehicleOptions,
];
},
typeChoices(): LOADPOINT_TYPE[] {
return Object.values(LOADPOINT_TYPE);
},
loadpointType(): LOADPOINT_TYPE | null {
return this.selectedType ?? this.chargerType;
},
addChargerLabel() {
if (this.loadpointType) {
return this.$t(`config.loadpoint.addCharger.${this.loadpointType}`);
}
return "";
},
},
watch: {
isModalVisible(visible) {
@ -728,6 +788,7 @@ export default {
},
methods: {
reset() {
this.selectedType = null;
this.values = deepClone(defaultValues);
this.updatePhases();
},
@ -748,10 +809,9 @@ export default {
const values = deepClone(this.values);
await api.put(`config/loadpoints/${this.id}`, values);
this.$emit("updated");
this.$refs.modal.close();
(this.$refs["modal"] as any).close();
} catch (e) {
console.error(e);
alert("update failed");
handleError(e, "update failed");
}
this.saving = false;
},
@ -759,7 +819,7 @@ export default {
try {
await api.delete(`config/loadpoints/${this.id}`);
this.$emit("updated");
this.$refs.modal.close();
(this.$refs["modal"] as any).close();
} catch (e) {
console.error(e);
alert("delete failed");
@ -770,11 +830,9 @@ export default {
try {
await api.post("config/loadpoints", this.values);
this.$emit("updated");
this.$refs.modal.close();
(this.$refs["modal"] as any).close();
} catch (e) {
console.error(e);
const error = e.response?.data?.error;
alert(`failed to create loadpoint: ${error}`);
handleError(e, "create failed");
}
this.saving = false;
},
@ -785,21 +843,20 @@ export default {
this.$emit("opened");
},
onClose() {
this.showAllSelected = false;
this.isModalVisible = false;
},
editCharger() {
this.$emit("openChargerModal", this.values.charger);
this.$emit("openChargerModal", this.values.charger, this.loadpointType);
},
editMeter() {
this.$emit("openMeterModal", this.values.meter);
},
// called externally
setMeter(meter) {
setMeter(meter: string) {
this.values.meter = meter;
},
// called externally
setCharger(charger) {
setCharger(charger: string) {
this.values.charger = charger;
},
updateChargerPower() {
@ -835,6 +892,9 @@ export default {
return;
}
},
selectType(type: LOADPOINT_TYPE) {
this.selectedType = type;
},
},
};
</script>

View file

@ -9,12 +9,12 @@
@open="open"
@close="close"
>
<div v-if="!meterType">
<div v-if="!meterType" class="d-flex flex-column gap-4">
<NewDeviceButton
v-for="t in typeChoices"
:key="t"
:title="$t(`config.meter.option.${t}`)"
class="mb-4 addButton"
class="addButton"
@click="selectType(t)"
/>
</div>

View file

@ -1,14 +1,13 @@
<template>
<li class="root" :class="{ attention }">
<button
class="d-flex align-items-center justify-content-center p-3"
tabindex="0"
@click="$emit('click')"
>
<shopicon-regular-plus class="me-1"></shopicon-regular-plus>
{{ title }}
</button>
</li>
<button
class="root d-flex align-items-center justify-content-center"
:class="{ attention }"
tabindex="0"
@click="$emit('click')"
>
<shopicon-regular-plus class="me-1"></shopicon-regular-plus>
<span class="text-start">{{ title }}</span>
</button>
</template>
<script>
@ -26,31 +25,21 @@ export default {
<style scoped>
.root {
padding: 0;
display: block;
list-style-type: none;
min-height: 9rem;
border-radius: 1rem;
border: 1px solid var(--evcc-gray-50);
padding: 1rem 1rem 0.5rem;
padding: 2rem;
transition: border-color var(--evcc-transition-fast) linear;
background: none;
width: 100%;
color: inherit;
margin: 0;
}
.root:hover,
.root:focus-within {
border-color: var(--evcc-default-text);
color: var(--evcc-default-text);
}
button {
border-radius: 1rem;
background: none;
border: none;
height: 100%;
width: 100%;
color: inherit;
}
button:focus {
outline: none;
}
.attention {
animation: wiggle 3s cubic-bezier(0.36, 0.07, 0.19, 0.97) infinite;
}

View file

@ -33,7 +33,6 @@
class="btn btn-outline-secondary"
:class="key === value ? 'active' : ''"
:for="`icon_${key}`"
:aria-label="key"
>
<VehicleIcon v-if="key" :name="key" />
<shopicon-regular-minus v-else></shopicon-regular-minus>

View file

@ -1,6 +1,6 @@
## required attributes
## required attributes [type: custom]
status: # charger status [A..F]
status: # charger status (A: not connected, B: connected, C: charging)
source: const
value: "A"
enabled: # is charging enabled?
@ -27,9 +27,6 @@ maxcurrent: # set maximum charge current in A
#soc: # state of charge in %
# source: const
# value: 75
#phases: # number of physical phases (1..3)
# source: const
# value: 3
#powers: # phase powers in W
# - source: const
# value: 3600
@ -51,27 +48,16 @@ maxcurrent: # set maximum charge current in A
# value: 230.2
# - source: const
# value: 230.3
#temp: # current temperature in °C (heating)
# source: const
# value: 45.5
#templimit: # temperature limit in °C (heating)
# source: const
# value: 60
#getmode: # SG-Ready mode (heat pump)
# source: const
# value: 1
## optional attributes (writeable)
#maxcurrentmilis: # set maximum charge current in A with decimal precision
#maxcurrentmillis: # set maximum charge current in A with decimal precision
# source: js
# script: console.log(maxcurrentmilis);
# script: console.log(maxcurrentmillis);
#phases1p3p: # switch phases (requires 'tos: true')
# source: js
# script: console.log(phases1p3p);
#tos: true
#wakeup: # wake up vehicle
# source: js
# script: console.log(wakeup);
#setmode: # change SG-Ready mode (1: normal, 2: boost, 3: stop)
# source: js
# script: console.log(setmode);

View file

@ -0,0 +1,54 @@
## required attributes [type: custom]
status: # heating status (B: standby, C: heating)
source: const
value: "B"
enabled: # is heating enabled?
source: const
value: true
enable: # enable/disable charging
source: js
script: console.log(enable)
maxcurrent: # set maximum heating current in A
source: js
script: console.log(maxcurrent)
features:
- heating # treat as a heating device
- integrateddevice # no charging sessions, no connected vehicles
## optional attributes (read-only)
#power: # heating power in W
# source: const
# value: 11000
#energy: # meter reading in kWh
# source: const
# value: 42.5
#powers: # phase powers in W
# - source: const
# value: 3600
# - source: const
# value: 3700
# - source: const
# value: 3800
#currents: # phase currents in A
# - source: const
# value: 16.0
# - source: const
# value: 16.1
# - source: const
# value: 16.2
#voltages: # phase voltages in V
# - source: const
# value: 230.1
# - source: const
# value: 230.2
# - source: const
# value: 230.3
## optional attributes (writeable)
#maxcurrentmillis: # set maximum heating current in A with decimal precision
# source: js
# script: console.log(maxcurrentmillis);

View file

@ -0,0 +1,23 @@
## required attributes [type: heatpump]
setmaxpower: # update the maximum heating power
source: js
script: console.log(setmaxpower); #
## optional attributes (read-only)
#getmaxpower: # heating power in W
# source: const
# value: 5000
#power: # heating power in W
# source: const
# value: 2000
#energy: # meter reading in kWh
# source: const
# value: 42.5
#temp: # current temperature (°C)
# source: const
# value: 45.5
#limittemp: # temperature limit (°C) configured in device
# source: const
# value: 60

View file

@ -0,0 +1,29 @@
## required attributes [type: sgready]
setmode: # set operation mode (1: reduced, 2: normal, 3 boost)
source: js
script: console.log(setmode) #
## optional attributes (read-only)
#getmode: # operation mode (1: reduced, 2: normal, 3 boost)
# source: const
# value: 2
#power: # charge power in W
# source: const
# value: 11000
#energy: # meter reading in kWh
# source: const
# value: 42.5
#temp: # current temperature (°C)
# source: const
# value: 42
#limittemp: # temperature limit (°C) configured in device
# source: const
# value: 84
## optional attributes (writeable)
#setmaxpower: # update the maximum charging power
# source: js
# script: console.log(setmaxpower);

View file

@ -0,0 +1,15 @@
## required attributes [type: sgready-boost]
charger: # configuration of a switch controlling the sg-ready port
type: template
template: shelly # example shelly
host: 192.168.0.101 #
## optional attributes (read-only)
#temp: # current temperature (°C)
# source: const
# value: 42
#limittemp: # temperature limit (°C) configured in device
# source: const
# value: 84

View file

@ -0,0 +1,24 @@
## required attributes [type: switchsocket]
enabled: # is switch enabled?
source: const
value: true
enable: # enable/disable switch
source: js
script: console.log(enable)
power: # charge power reading in W
source: const
value: 11000
standbypower: 20 # in W, below values will be treaded as inactive
features:
- integrateddevice # no charging sessions, no connected vehicles
## optional attributes (read-only)
#energy: # meter reading in kWh
# source: const
# value: 42.5
#soc: # charge level (%) of the connected device
# source: const
# value: 75

View file

@ -0,0 +1,25 @@
## required attributes [type: switchsocket]
enabled: # is switch enabled?
source: const
value: true
enable: # enable/disable switch
source: js
script: console.log(enable)
power: # charge power reading in W
source: const
value: 11000
standbypower: 20 # in W, below values will be treaded as inactive
features:
- heating # treat as a heating device
- integrateddevice # no charging sessions, no connected vehicles
## optional attributes (read-only)
#energy: # meter reading in kWh
# source: const
# value: 42.5
#soc: # temperature (°C) of the connected device
# source: const
# value: 75

View file

@ -1,5 +1,11 @@
<template>
<component :is="singleIcon" v-if="single" :class="`icon icon--${size}`"></component>
<component
:is="singleIcon"
v-if="single"
:class="`icon icon--${size}`"
role="img"
:aria-label="name"
></component>
<MultiIcon v-else :count="count" :size="size"></MultiIcon>
</template>

View file

@ -114,6 +114,11 @@ export enum PHASES {
THREE_PHASES = 3,
}
export enum LOADPOINT_TYPE {
CHARGING = "charging",
HEATING = "heating",
}
export type SessionInfoKey =
| "remaining"
| "finished"

View file

@ -18,7 +18,7 @@
>
{{ $t("config.main.loadpointRequired") }}
</p>
<ul class="p-0 config-list">
<div class="p-0 config-list">
<DeviceCard
v-for="loadpoint in loadpoints"
:key="loadpoint.name"
@ -47,10 +47,10 @@
:attention="loadpointsRequired"
@click="newLoadpoint"
/>
</ul>
</div>
<h2 class="my-4">{{ $t("config.section.vehicles") }} 🧪</h2>
<ul class="p-0 config-list">
<div class="p-0 config-list">
<DeviceCard
v-for="vehicle in vehicles"
:key="vehicle.name"
@ -73,10 +73,10 @@
:title="$t('config.main.addVehicle')"
@click="newVehicle"
/>
</ul>
</div>
<h2 class="my-4 mt-5">{{ $t("config.section.grid") }} 🧪</h2>
<ul class="p-0 config-list">
<div class="p-0 config-list">
<DeviceCard
v-if="gridMeter"
:title="$t('config.grid.title')"
@ -120,9 +120,9 @@
data-testid="add-tariffs"
@click="openModal('tariffsModal')"
/>
</ul>
</div>
<h2 class="my-4 mt-5">{{ $t("config.section.meter") }} 🧪</h2>
<ul class="p-0 config-list">
<div class="p-0 config-list">
<DeviceCard
v-for="meter in pvMeters"
:key="meter.name"
@ -169,10 +169,10 @@
:title="$t('config.main.addPvBattery')"
@click="addSolarBatteryMeter"
/>
</ul>
</div>
<h2 class="my-4 mt-5">{{ $t("config.section.additionalMeter") }} 🧪</h2>
<ul class="p-0 config-list">
<div class="p-0 config-list">
<DeviceCard
v-for="meter in auxMeters"
:key="meter.name"
@ -198,11 +198,11 @@
:title="$t('config.main.addAdditional')"
@click="newAdditionalMeter"
/>
</ul>
</div>
<h2 class="my-4 mt-5">{{ $t("config.section.integrations") }} 🧪</h2>
<ul class="p-0 config-list">
<div class="p-0 config-list">
<DeviceCard
:title="$t('config.mqtt.title')"
editable
@ -303,7 +303,7 @@
<DeviceTags :tags="hemsTags" />
</template>
</DeviceCard>
</ul>
</div>
</div>
<hr class="my-5" />
@ -348,6 +348,7 @@
<ChargerModal
:id="selectedChargerId"
:name="selectedChargerName"
:loadpointType="selectedLoadpointType"
:fade="loadpointSubModalOpen ? 'right' : ''"
:isSponsor="isSponsor"
@added="chargerAdded"
@ -467,6 +468,7 @@ export default {
selectedMeterTypeChoices: [],
selectedChargerId: undefined,
selectedLoadpointId: undefined,
selectedLoadpointType: undefined,
loadpointSubModalOpen: false,
site: { grid: "", pv: [], battery: [], title: "" },
deviceValueTimeout: undefined,
@ -689,7 +691,7 @@ export default {
chargerModal() {
return Modal.getOrCreateInstance(document.getElementById("chargerModal"));
},
editLoadpointCharger(name) {
editLoadpointCharger(name, loadpointType) {
this.loadpointSubModalOpen = true;
const charger = this.chargers.find((c) => c.name === name);
if (charger && charger.id === undefined) {
@ -699,7 +701,7 @@ export default {
return;
}
this.loadpointModal().hide();
this.$nextTick(() => this.editCharger(charger?.id));
this.$nextTick(() => this.editCharger(charger?.id, loadpointType));
},
editLoadpointMeter(name) {
this.loadpointSubModalOpen = true;
@ -733,12 +735,9 @@ export default {
this.selectedMeterTypeChoices = ["aux", "ext"];
this.$nextTick(() => this.meterModal().show());
},
editCharger(id) {
editCharger(id, loadpointType) {
this.selectedChargerId = id;
this.$nextTick(() => this.chargerModal().show());
},
newCharger() {
this.selectedChargerId = undefined;
this.selectedLoadpointType = loadpointType;
this.$nextTick(() => this.chargerModal().show());
},
async meterChanged() {
@ -806,7 +805,7 @@ export default {
meterRemoved(type) {
if (type === "charge") {
// update loadpoint
this.$refs.loadpointModal?.setMeter(undefined);
this.$refs.loadpointModal?.setMeter("");
} else {
// update site grid, pv, battery, aux, ext
this.loadSite();
@ -819,7 +818,7 @@ export default {
this.$refs.loadpointModal?.setCharger(name);
},
chargerRemoved() {
this.$refs.loadpointModal?.setCharger(undefined);
this.$refs.loadpointModal?.setCharger("");
this.chargerChanged();
},
meterModalClosed() {
@ -920,7 +919,8 @@ export default {
},
chargerIcon(chargerName) {
const charger = this.chargers.find((c) => c.name === chargerName);
return charger?.config?.icon;
return charger?.config?.icon || this.deviceValues?.charger?.[chargerName]?.icon?.value;
},
},
};