Skip to content

Verbraucher: Refactor für ResetChargemode auf einmalig, täglich, wöchentlich - #4024

Open
LKuemmel wants to merge 7 commits into
openWB:masterfrom
LKuemmel:auto_usage_switch
Open

LKuemmel wants to merge 7 commits into
openWB:masterfrom
LKuemmel:auto_usage_switch

Conversation

@LKuemmel

@LKuemmel LKuemmel commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Critical reset scheduling and default-state issues, along with migration gaps, remain unresolved.

Review effort: Lite
Findings: 2 High severity · 1 Medium severity

Open (3)
What changed in this PR

Refactors consumer charge-mode resets to use reusable timepoint plans and migrates legacy reset settings.

Changes:

  • Adds one-time, daily, and weekly reset scheduling.
  • Adds datastore migration support.
  • Updates reset handling and related tests.
File Summary
packages/​helpermodules/​update_config.py Migrates legacy reset configurations.
packages/​helpermodules/​update_config_test.py Tests migration behavior.
packages/​helpermodules/​timecheck.py Supports timepoint scheduling.
packages/​helpermodules/​abstract_plans.py Adds the reusable timepoint base class.
packages/​control/​consumer/​consumer.py Applies scheduled resets; recurring due-time handling requires correction.
packages/​control/​consumer/​consumer_test.py Tests reset execution.
packages/​control/​consumer/​consumer_data.py Defines the reset schema; default behavior requires correction.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread packages/control/consumer/consumer.py Outdated
Comment on lines +469 to +470
if ((data.data.general_data.data.control_interval * -1 < timecheck.check_end_time(
self.data.usage.reset_chargemode) <= 0) and
Comment on lines +37 to 38
class ResetChargemode(TimepointPlan):
chargemode: Chargemode = Chargemode.INSTANT_CHARGING
Comment thread packages/helpermodules/update_config.py Outdated
Comment on lines +3942 to +3958
if reset_chargemode.get("mode") is not None:
# altes Schema
if reset_chargemode["mode"] == "never":
reset_chargemode = ResetChargemode(active=False)
elif reset_chargemode["mode"] == "midnight":
reset_chargemode = ResetChargemode(active=True, time="00:00",
frequency=FrequencyDate(selected="daily"))
elif reset_chargemode["mode"] == "time":
timestamp = reset_chargemode["time"]
if timestamp is not None:
date = datetime.datetime.fromtimestamp(timestamp).strftime("%Y-%m-%d")
time = datetime.datetime.fromtimestamp(timestamp).strftime("%H:%M")
else:
date = datetime.datetime.today().strftime("%Y-%m-%d")
time = "07:00"
reset_chargemode = ResetChargemode(
active=True, time=time, frequency=FrequencyDate(selected="once", once=date))

@Brett-S-OWB Brett-S-OWB left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Vorgeschlagene Änderungen: Der Toggle und die Auswahl der Wochentage sollten aus Konsistenzgründen mit anderen Bereichen des Koala-Themes übereinstimmen.

Image

Comment on lines 21 to 37
<div class="text-subtitle2">Betriebsmodus umstellen</div>
<q-btn-group spread outline class="q-mt-sm">
<q-btn
v-for="trigger in resetTriggers"
:key="trigger.value"
size="sm"
:outline="resetTrigger !== trigger.value"
:color="resetTrigger === trigger.value ? 'primary' : 'grey'"
:label="trigger.label"
@click="selectTrigger(trigger.value)"
:outline="resetEnabled"
:color="!resetEnabled ? 'negative' : 'grey'"
label="Nein"
@click="setResetEnabled(false)"
/>
<q-btn
size="sm"
:outline="!resetEnabled"
:color="resetEnabled ? 'positive' : 'grey'"
label="Ja"
@click="setResetEnabled(true)"
/>
</q-btn-group>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Das sollte ein Toggle sein, damit es mit den anderen Komponenten im Theme konsistent bleibt.

Suggested change
<div class="text-subtitle2">Betriebsmodus umstellen</div>
<q-btn-group spread outline class="q-mt-sm">
<q-btn
v-for="trigger in resetTriggers"
:key="trigger.value"
size="sm"
:outline="resetTrigger !== trigger.value"
:color="resetTrigger === trigger.value ? 'primary' : 'grey'"
:label="trigger.label"
@click="selectTrigger(trigger.value)"
:outline="resetEnabled"
:color="!resetEnabled ? 'negative' : 'grey'"
label="Nein"
@click="setResetEnabled(false)"
/>
<q-btn
size="sm"
:outline="!resetEnabled"
:color="resetEnabled ? 'positive' : 'grey'"
label="Ja"
@click="setResetEnabled(true)"
/>
</q-btn-group>
<div class="row items-center justify-between">
<div class="text-subtitle2 q-mr-sm">Betriebsmodus umstellen</div>
<ToggleStandard
:model-value="resetEnabled"
:size="'sm'"
color="positive"
@update:model-value="setResetEnabled"
/>
</div>

Comment on lines +39 to +45
<template v-if="resetEnabled">
<q-input
v-model="resetTimeOfDay"
v-model="resetTime"
type="time"
label="Uhrzeit"
class="col"
class="q-mt-sm"
/>

@Brett-S-OWB Brett-S-OWB Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Formatting

Suggested change
<template v-if="resetEnabled">
<q-input
v-model="resetTimeOfDay"
v-model="resetTime"
type="time"
label="Uhrzeit"
class="col"
class="q-mt-sm"
/>
<template v-if="resetEnabled">
<q-separator inset class="q-mt-sm" />
<q-input v-model="resetTime" type="time" label="Uhrzeit" />

Comment on lines +68 to +87
<div
v-if="resetMode === 'weekly'"
class="row q-col-gutter-xs q-mt-sm"
>
<div
v-for="(day, index) in weekDays"
:key="day"
class="col"
>
<q-btn
no-caps
size="sm"
class="full-width"
:outline="!resetWeeklyDays[index]"
:color="resetWeeklyDays[index] ? 'primary' : 'grey'"
:label="day"
@click="toggleWeeklyDay(index)"
/>
</div>
</div>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Die Auswahl der Wochentage sollte das gleiche grafische Format haben wie in anderen Bereichen der Koala Theme.

Suggested change
<div
v-if="resetMode === 'weekly'"
class="row q-col-gutter-xs q-mt-sm"
>
<div
v-for="(day, index) in weekDays"
:key="day"
class="col"
>
<q-btn
no-caps
size="sm"
class="full-width"
:outline="!resetWeeklyDays[index]"
:color="resetWeeklyDays[index] ? 'primary' : 'grey'"
:label="day"
@click="toggleWeeklyDay(index)"
/>
</div>
</div>
<div
v-if="resetMode === 'weekly'"
class="row items-center q-gutter-sm justify-center no-wrap q-mt-xs"
>
<div v-for="(day, index) in weekDays" :key="day">
<q-btn
round
:size="$q.platform.is.mobile ? '0.8rem' : '0.7rem'"
:flat="!resetWeeklyDays[index]"
:outline="resetWeeklyDays[index]"
color="primary"
:label="day"
:class="{ deselected: !resetWeeklyDays[index] }"
@click="toggleWeeklyDay(index)"
/>
</div>
</div>

import { useMqttStore } from 'src/stores/mqtt-store';
import { useChargeModes } from 'src/composables/useChargeModes';
import type { ConsumerResetTrigger } from 'src/stores/mqtt-store-model';
import ConsumerModeButtons from './ConsumerModeButtons.vue';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Standard-Toggle import für toggle

Suggested change
import ConsumerModeButtons from './ConsumerModeButtons.vue';
import ToggleStandard from './ToggleStandard.vue';

Comment on lines 205 to 207
const showModeControls = computed(
() => consumerUsageType.value !== 'meter_only' && consumerUsageType.value !== 'self_controlled',
);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Formatting

Suggested change
const showModeControls = computed(
() =>
consumerUsageType.value !== 'meter_only' &&
consumerUsageType.value !== 'self_controlled',
);

@LKuemmel
LKuemmel requested a review from Brett-S-OWB October 2, 2026 13:10

@Brett-S-OWB Brett-S-OWB left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Änderungen in Koala Theme passen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants