Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add schedule for planner #16091

Merged
merged 132 commits into from
Dec 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
132 commits
Select commit Hold shift + click to select a range
eb0cb24
wip
Maschga Sep 12, 2024
a3a936c
weip
Maschga Sep 13, 2024
6e952d9
wip
Maschga Sep 13, 2024
6c6c591
running lint
Maschga Sep 13, 2024
584b78a
wip
Maschga Sep 13, 2024
618e8ca
remove comment
Maschga Sep 13, 2024
762b84d
running lint
Maschga Sep 13, 2024
3a89e00
replacing `repetitive` with `repeating`
Maschga Sep 16, 2024
01ee9ca
better id-name
Maschga Sep 16, 2024
561eb32
using unique id-name
Maschga Sep 16, 2024
39c70e7
removing unnecessary parameter `socBasedPlanning`
Maschga Sep 16, 2024
88a8ae9
Merge branch 'add-schedule-for-planner' of github.com:Maschga/evcc in…
Maschga Sep 16, 2024
3ab074c
using `Intl` to get weekdays-translations
Maschga Sep 16, 2024
d308765
fix bug
Maschga Sep 16, 2024
b85c08d
add unit tests for `getShortenedWeekdaysLabel()`-method
Maschga Sep 16, 2024
46b78f9
fix syntax bug
Maschga Sep 16, 2024
1727afc
using `this.$i18n?.locale`
Maschga Sep 16, 2024
685ef0b
rewriting tests for english weekdays
Maschga Sep 16, 2024
cf9dc23
Revert "rewriting tests for english weekdays"
Maschga Sep 16, 2024
b9f6d7e
fix test
Maschga Sep 16, 2024
e56ccbb
add newline at end of file
Maschga Sep 16, 2024
1e12244
giving tags unique data-testids
Maschga Sep 16, 2024
a07f746
use hyphen only for more than 2 consecutive weekdays
Maschga Sep 28, 2024
0645cc3
using en-dash and whitespaces
Maschga Sep 28, 2024
6851ffe
add missing `-`
Maschga Sep 28, 2024
f079ea6
make data-testid unique
Maschga Sep 28, 2024
a0cb4d0
sort toml keys alphabetically
Maschga Oct 4, 2024
0ad95a1
update event names
Maschga Oct 4, 2024
a280d31
run lint
Maschga Oct 4, 2024
05e8e17
rename variables
Maschga Oct 4, 2024
1c8172d
wip: implement backend
Maschga Oct 4, 2024
568b2fb
remove unused import
Maschga Oct 4, 2024
77fdab2
make key camelCase
Maschga Oct 5, 2024
77a5fd6
run porcelain
Maschga Oct 5, 2024
b585907
Update mock.go
Maschga Oct 5, 2024
a3d652f
remove name `entry` + wip: implement backend
Maschga Oct 7, 2024
51c1f87
change key to `repeatingPlans`
Maschga Oct 7, 2024
2eb2417
synchronize data via websocket
Maschga Oct 8, 2024
e4411d6
recursion fix
naltatis Oct 14, 2024
22cd019
use key `plans` instead of `repeatingPlans`
Maschga Oct 14, 2024
ce592b4
use `splice()` instead of `Object.assign` to avoid a reference
Maschga Oct 14, 2024
d0ae604
improve debug message
Maschga Oct 14, 2024
fa9d77f
remove comment
Maschga Oct 14, 2024
0672649
remove unnecessary tag
Maschga Oct 14, 2024
171bad6
add tag for space
Maschga Oct 14, 2024
4c1f580
show apply-button on the right side
Maschga Oct 14, 2024
319abef
run lint
Maschga Oct 14, 2024
a5aa0f8
lower first character of variable
Maschga Oct 14, 2024
d856c8f
WIP: show next plan
Maschga Oct 18, 2024
c3cd3aa
avoid circular import
Maschga Oct 19, 2024
fac2ab5
disable last remaining field
Maschga Oct 21, 2024
6c22e58
correct name
Maschga Oct 21, 2024
fa77c94
handle utc
Maschga Oct 21, 2024
b5ef2c6
add onlyActivePlans-parameter
Maschga Oct 21, 2024
af83894
fix bugs
Maschga Oct 27, 2024
bfd883f
fix test
Maschga Oct 28, 2024
6fabcf2
Merge remote-tracking branch 'upstream/master' into add-schedule-for-…
Maschga Oct 28, 2024
3337d15
run porcelain
Maschga Oct 28, 2024
f4d343b
fix tests
Maschga Oct 28, 2024
aa4ddcf
run lint
Maschga Oct 28, 2024
ff42d34
fix bug
Maschga Oct 28, 2024
77f9c79
rename method `vehiclePlanSoc()` to `nextVehiclePlanSoc()`
Maschga Nov 2, 2024
841d080
rename `AdapterStruct` to `adapter`
Maschga Nov 2, 2024
795f1a4
update the time format on language-change
Maschga Nov 2, 2024
e40f0fd
rename functions
Maschga Nov 11, 2024
fa76656
get next plan
Maschga Nov 11, 2024
fc673c2
refactor code
Maschga Nov 11, 2024
0facffe
begin week with sunday
Maschga Nov 11, 2024
4daa42c
add test for `getWeekdaysList()`
Maschga Nov 11, 2024
27f403f
add `getNextLocalePlan()`
Maschga Nov 11, 2024
a147c1b
add preview for repeating plans
Maschga Nov 11, 2024
b38d2bb
manually select plan to preview
Maschga Nov 16, 2024
6eba567
allow to select no option
Maschga Nov 17, 2024
74246e4
move saturday to the end
Maschga Nov 17, 2024
167d98d
add active-plan-option
Maschga Nov 17, 2024
1dd850b
fix tests for `getShortenedWeekdaysLabel()`
Maschga Nov 17, 2024
b7cecc1
run lint
Maschga Nov 17, 2024
866e58a
use german translation in test
Maschga Nov 17, 2024
fadc8bf
move css-class
Maschga Nov 17, 2024
7842541
remove log statement
Maschga Nov 17, 2024
803ffa5
replace `-` with `–`
Maschga Nov 17, 2024
720f785
parse time to Date
Maschga Nov 17, 2024
5c05422
return correct id when soc not available
Maschga Nov 17, 2024
2dd6520
refetch `nextPlanId` when `effectivePlanTime` has changed
Maschga Nov 17, 2024
9ae49ad
change expected text in test
Maschga Nov 17, 2024
d6c8e74
Revert "change expected text in test"
Maschga Nov 17, 2024
b13d8fd
number plans when at least one repeating plan exist
Maschga Nov 17, 2024
7497f73
run lint
Maschga Nov 17, 2024
0184147
fix test
Maschga Nov 17, 2024
d27a80e
move numbers to the right
Maschga Nov 17, 2024
64ba015
fix wrong title-display
Maschga Nov 17, 2024
7dfc3fb
move warnings up
Maschga Nov 17, 2024
65329b8
add `data-testid`
Maschga Nov 17, 2024
9cb5c69
change defaults
Maschga Nov 17, 2024
78e5669
change default time
Maschga Nov 17, 2024
1e9fb3e
Merge branch 'master' into add-schedule-for-planner
naltatis Nov 18, 2024
12d941b
ui tweaks, spacing, wording
naltatis Nov 18, 2024
645c1f9
simplify next occurance handling, reduce public api
naltatis Nov 19, 2024
1c3eeca
Merge branch 'master' into add-schedule-for-planner
naltatis Nov 19, 2024
9b7b46a
rework the storage of repeating plans
Maschga Nov 19, 2024
7c732f2
add e2e: check repeating feature availability
naltatis Nov 20, 2024
a7d4152
skip plans if there are no selected weekdays
Maschga Nov 20, 2024
b9c5fd3
reduce api-calls
Maschga Nov 20, 2024
9de9585
use plan-keyword
Maschga Nov 20, 2024
155e5fd
add comment
Maschga Nov 20, 2024
765f502
id nameing scheme; small layout improvements
naltatis Nov 20, 2024
78ef533
pass proper value to update()-method
Maschga Nov 20, 2024
7fc734d
Merge branch 'add-schedule-for-planner' of github.com:Maschga/evcc in…
Maschga Nov 20, 2024
3c8f7c2
use CustomSelect-component
Maschga Nov 20, 2024
073e89b
reduce api-calls, handle plan-deletion
Maschga Nov 20, 2024
197b207
run lint
Maschga Nov 20, 2024
8a69848
show next active plan
Maschga Nov 25, 2024
651940b
disable preview-options if a plan is active
Maschga Nov 25, 2024
b65f9ce
run lint
Maschga Nov 25, 2024
7d3b821
rewrite logic
Maschga Nov 25, 2024
5aedf2f
add time marker
naltatis Nov 25, 2024
9d22eb8
add out of range target
naltatis Nov 26, 2024
75a61f5
better alignment of delete and apply button
naltatis Nov 26, 2024
0429d9d
Merge branch 'master' into add-schedule-for-planner
naltatis Nov 26, 2024
dd27309
refactoring; removed local state where possible; simplified preview u…
naltatis Nov 27, 2024
a26dbb2
simplify vehicle plan api (arr > obj); replace manual utc/offset conv…
naltatis Nov 27, 2024
f141022
adjust e2e
naltatis Nov 27, 2024
43f9193
fixed time calculation; improve next time marker ui
naltatis Nov 28, 2024
73ea683
mobile styles; a11y, tab navigation
naltatis Nov 28, 2024
f9195a7
fix test
naltatis Nov 28, 2024
f6080c7
add e2e test: add/remove repeating
naltatis Nov 28, 2024
0360810
Merge branch 'master' into add-schedule-for-planner
naltatis Nov 28, 2024
fdf5710
add e2e: preview
naltatis Nov 29, 2024
0d8c764
add e2e: weekdays
naltatis Nov 29, 2024
3eb26b7
add e2e test: next plan
naltatis Nov 29, 2024
f0b5a58
add e2e test: persistance
naltatis Nov 29, 2024
f0236a2
Merge branch 'master' into add-schedule-for-planner
naltatis Nov 29, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions api/plans.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package api

type RepeatingPlanStruct struct {
Weekdays []int `json:"weekdays"` // 0-6 (Sunday-Saturday)
Time string `json:"time"` // HH:MM
Tz string `json:"tz"` // timezone in IANA format
Soc int `json:"soc"`
Active bool `json:"active"`
}
4 changes: 4 additions & 0 deletions assets/css/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -632,3 +632,7 @@ html.app .modal-dialog {
.alert-danger code {
color: var(--evcc-darkest-green);
}

input::-webkit-date-and-time-value {
text-align: left;
}
49 changes: 35 additions & 14 deletions assets/js/components/ChargingPlan.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@
data-testid="charging-plan"
>
<div class="value m-0 d-block align-items-baseline justify-content-center">
<button class="value-button p-0" :class="buttonColor" @click="openModal">
<button
class="value-button p-0"
:class="buttonColor"
data-testid="charging-plan-button"
@click="openModal"
>
<strong v-if="enabled">
<span class="targetTimeLabel"> {{ targetTimeLabel }}</span>
<div
Expand All @@ -33,6 +38,7 @@
tabindex="-1"
role="dialog"
aria-hidden="true"
data-testid="charging-plan-modal"
>
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
Expand Down Expand Up @@ -74,11 +80,12 @@
</li>
</ul>
<div v-if="isModalVisible">
<ChargingPlanSettings
<ChargingPlansSettings
v-if="departureTabActive"
v-bind="chargingPlanSettingsProps"
@plan-updated="updatePlan"
@plan-removed="removePlan"
v-bind="chargingPlansSettingsProps"
@static-plan-updated="updateStaticPlan"
@static-plan-removed="removeStaticPlan"
@repeating-plans-updated="updateRepeatingPlans"
/>
<ChargingPlanArrival
v-if="arrivalTabActive"
Expand All @@ -98,7 +105,7 @@
<script>
import Modal from "bootstrap/js/dist/modal";
import LabelAndValue from "./LabelAndValue.vue";
import ChargingPlanSettings from "./ChargingPlanSettings.vue";
import ChargingPlansSettings from "./ChargingPlansSettings.vue";
import ChargingPlanArrival from "./ChargingPlanArrival.vue";

import formatter from "../mixins/formatter";
Expand All @@ -110,7 +117,7 @@ const ONE_MINUTE = 60 * 1000;

export default {
name: "ChargingPlan",
components: { LabelAndValue, ChargingPlanSettings, ChargingPlanArrival },
components: { LabelAndValue, ChargingPlansSettings, ChargingPlanArrival },
mixins: [formatter, collector],
props: {
currency: String,
Expand Down Expand Up @@ -162,12 +169,18 @@ export default {
limitSoc: function () {
return this.vehicle?.limitSoc;
},
plans: function () {
staticPlan: function () {
if (this.socBasedPlanning) {
return this.vehicle?.plans || [];
return this.vehicle?.plan;
}
if (this.planEnergy && this.planTime) {
return [{ energy: this.planEnergy, time: this.planTime }];
return { energy: this.planEnergy, time: this.planTime };
}
return null;
},
repeatingPlans: function () {
if (this.vehicle?.repeatingPlans.length > 0) {
return [...this.vehicle.repeatingPlans];
}
return [];
},
Expand All @@ -183,8 +196,8 @@ export default {
arrivalTabActive: function () {
return this.activeTab === "arrival";
},
chargingPlanSettingsProps: function () {
return this.collectProps(ChargingPlanSettings);
chargingPlansSettingsProps: function () {
return this.collectProps(ChargingPlansSettings);
},
chargingPlanArrival: function () {
return this.collectProps(ChargingPlanArrival);
Expand All @@ -211,6 +224,11 @@ export default {
effectivePlanTime() {
this.updateTargetTimeLabel();
},
"$i18n.locale": {
handler() {
this.updateTargetTimeLabel();
},
},
},
mounted() {
this.modal = Modal.getOrCreateInstance(this.$refs.modal);
Expand Down Expand Up @@ -263,21 +281,24 @@ export default {
showArrivalTab: function () {
this.activeTab = "arrival";
},
updatePlan: function ({ soc, time, energy }) {
updateStaticPlan: function ({ soc, time, energy }) {
const timeISO = time.toISOString();
if (this.socBasedPlanning) {
api.post(`${this.apiVehicle}plan/soc/${soc}/${timeISO}`);
} else {
api.post(`${this.apiLoadpoint}plan/energy/${energy}/${timeISO}`);
}
},
removePlan: function () {
removeStaticPlan: function () {
if (this.socBasedPlanning) {
api.delete(`${this.apiVehicle}plan/soc`);
} else {
api.delete(`${this.apiLoadpoint}plan/energy`);
}
},
updateRepeatingPlans: function (plans) {
api.post(`${this.apiVehicle}plan/repeating`, { plans });
},
setMinSoc: function (soc) {
api.post(`${this.apiVehicle}minsoc/${soc}`);
},
Expand Down
4 changes: 2 additions & 2 deletions assets/js/components/ChargingPlanPreview.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ describe("basics", () => {
result = wrapper.vm.slots;
});

test("should return 42 slots", () => {
expect(result.length).eq(42);
test("should return 39 slots", () => {
expect(result.length).eq(39);
});

test("slots should be an hour apart", () => {
Expand Down
37 changes: 34 additions & 3 deletions assets/js/components/ChargingPlanPreview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@
</div>
</div>
</div>
<TariffChart :slots="slots" @slot-hovered="slotHovered" />
<TariffChart
:slots="slots"
:target-text="targetText"
:target-offset="targetHourOffset"
@slot-hovered="slotHovered"
/>
</div>
</template>

Expand Down Expand Up @@ -114,12 +119,28 @@ export default {
}
return null;
},
targetHourOffset() {
if (!this.targetTime) {
return null;
}
const start = new Date(this.startTime);
start.setMinutes(0);
start.setSeconds(0);
start.setMilliseconds(0);
return (this.targetTime.getTime() - start.getTime()) / (60 * 60 * 1000);
},
targetText() {
if (!this.targetTime) {
return null;
}
return this.fmtWeekdayTime(this.targetTime);
},
slots() {
const result = [];
const rates = this.convertDates(this.rates);
const plan = this.convertDates(this.plan);
const oneHour = 60 * 60 * 1000;
for (let i = 0; i < 42; i++) {
for (let i = 0; i < 39; i++) {
const start = new Date(this.startTime.getTime() + oneHour * i);
const startHour = start.getHours();
start.setMinutes(0);
Expand All @@ -132,13 +153,23 @@ export default {
const toLate = this.targetTime && this.targetTime <= start;
// TODO: handle multiple matching time slots
const price = this.findSlotInRange(start, end, rates)?.price;
const isTarget = start <= this.targetTime && end > this.targetTime;
const charging = this.findSlotInRange(start, end, plan) != null;
const warning =
charging &&
this.targetTime &&
end > this.targetTime &&
this.targetTime < this.endTime;
result.push({ day, price, startHour, endHour, charging, toLate, warning });
result.push({
day,
price,
startHour,
endHour,
charging,
toLate,
warning,
isTarget,
});
}
return result;
},
Expand Down
Loading