Skip to content

Commit

Permalink
Ocpp: add disconnect required status (#15659)
Browse files Browse the repository at this point in the history
  • Loading branch information
andig authored Aug 25, 2024
1 parent f8b7f77 commit d03705e
Show file tree
Hide file tree
Showing 11 changed files with 103 additions and 29 deletions.
1 change: 1 addition & 0 deletions api/reason.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ type Reason int
const (
ReasonUnknown Reason = iota
ReasonWaitingForAuthorization
ReasonDisconnectRequired
)
20 changes: 12 additions & 8 deletions api/reason_enumer.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion assets/js/components/Loadpoint.vue
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ export default {
sessionSolarPercentage: Number,
// charger
chargerAwaitingAuthorization: Boolean,
chargerStatusReason: String,
chargerFeatureIntegratedDevice: Boolean,
chargerFeatureHeating: Boolean,
chargerIcon: String,
Expand Down
21 changes: 21 additions & 0 deletions assets/js/components/MaterialIcon/Reconnect.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<template>
<svg :style="svgStyle" viewBox="0 0 32 32">
<path
fill="currentColor"
d="M5.505,24.609c-0.595,-0.935 -0.94,-2.041 -0.94,-3.222c-0,-1.632 0.661,-3.198 1.831,-4.336l1.995,-1.994c0.52,-0.521 1.364,-0.521 1.885,0l0.391,0.391l1.724,-1.724c0.52,-0.52 1.365,-0.52 1.885,-0c0.52,0.52 0.52,1.365 0,1.885l-1.724,1.724l2.115,2.115l1.724,-1.724c0.52,-0.52 1.365,-0.52 1.885,-0c0.52,0.52 0.52,1.365 0,1.885l-1.724,1.724l0.391,0.391c0.521,0.521 0.521,1.365 -0,1.885c-0,0 -1.994,1.995 -1.994,1.995c-1.138,1.17 -2.704,1.831 -4.336,1.831c-1.181,0 -2.287,-0.345 -3.222,-0.94l-2.448,2.448c-0.521,0.52 -1.365,0.52 -1.886,-0c-0.52,-0.521 -0.52,-1.365 0,-1.886l2.448,-2.448Zm4.219,-6.333l-0.391,-0.39l-1.057,1.057c-0.005,0.005 -0.01,0.01 -0.015,0.015c-0.658,0.637 -1.03,1.514 -1.03,2.429c0,0.797 0.282,1.533 0.75,2.114c0.106,0.059 0.205,0.133 0.295,0.223c0.09,0.09 0.164,0.189 0.223,0.295c0.581,0.468 1.317,0.75 2.114,0.75c0.915,-0 1.792,-0.372 2.429,-1.03c0.005,-0.005 0.01,-0.01 0.015,-0.015c0,-0 1.057,-1.057 1.057,-1.057l-4.39,-4.391Zm14.885,-12.771l2.448,-2.448c0.521,-0.52 1.365,-0.52 1.886,0c0.52,0.521 0.52,1.365 -0,1.886l-2.448,2.448c0.595,0.935 0.94,2.041 0.94,3.222c0,1.632 -0.661,3.198 -1.831,4.336l-1.995,1.994c-0.52,0.521 -1.364,0.521 -1.885,-0l-6.667,-6.667c-0.521,-0.521 -0.521,-1.365 0,-1.885c0,-0 1.994,-1.995 1.994,-1.995c1.138,-1.17 2.704,-1.831 4.336,-1.831c1.181,-0 2.287,0.345 3.222,0.94Zm-0.59,2.994c-0.106,-0.059 -0.205,-0.133 -0.295,-0.223c-0.09,-0.09 -0.164,-0.189 -0.223,-0.295c-0.581,-0.468 -1.317,-0.75 -2.114,-0.75c-0.915,0 -1.792,0.372 -2.429,1.03c-0.005,0.005 -0.01,0.01 -0.015,0.015c-0,0 -1.057,1.057 -1.057,1.057l4.781,4.781l1.057,-1.057c0.005,-0.005 0.01,-0.01 0.015,-0.015c0.658,-0.637 1.03,-1.514 1.03,-2.429c-0,-0.797 -0.282,-1.533 -0.75,-2.114Z"
/>
<path
fill="currentColor"
d="M25.333,20l0.781,-0l-0.39,-0.391c-0.52,-0.52 -0.52,-1.365 -0,-1.885c0.52,-0.52 1.365,-0.52 1.885,-0l2.667,2.667c0.387,0.386 0.492,0.962 0.289,1.453c-0.066,0.161 -0.164,0.308 -0.289,0.432l-2.667,2.667c-0.52,0.52 -1.365,0.52 -1.885,-0c-0.52,-0.521 -0.52,-1.365 -0,-1.886l0.39,-0.39l-0.781,-0c-1.463,-0 -2.666,1.203 -2.666,2.666c-0,1.463 1.203,2.667 2.666,2.667c0.656,-0 1.289,-0.242 1.778,-0.679c0.549,-0.491 1.392,-0.444 1.883,0.105c0.49,0.548 0.443,1.392 -0.105,1.882c-0.978,0.875 -2.244,1.359 -3.556,1.359c-2.926,-0 -5.333,-2.408 -5.333,-5.334c-0,-2.925 2.408,-5.333 5.333,-5.333Z"
/>
</svg>
</template>

<script>
import icon from "../../mixins/icon";
export default {
name: "Reconnect",
mixins: [icon],
};
</script>
2 changes: 1 addition & 1 deletion assets/js/components/Vehicle.vue
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export default {
integratedDevice: Boolean,
limitEnergy: Number,
mode: String,
chargerAwaitingAuthorization: Boolean,
chargerStatusReason: String,
phaseAction: String,
phaseRemainingInterpolated: Number,
planActive: Boolean,
Expand Down
59 changes: 47 additions & 12 deletions assets/js/components/VehicleStatus.vue
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,15 @@
>
<RfidWaitIcon />
</div>
<div
v-if="disconnectRequiredVisible"
ref="disconnectRequired"
class="entry text-warning"
data-bs-toggle="tooltip"
data-testid="vehicle-status-disconnect-required"
>
<ReconnectIcon />
</div>

<!-- smart cost -->
<button
Expand Down Expand Up @@ -148,39 +157,44 @@ import DynamicPriceIcon from "./MaterialIcon/DynamicPrice.vue";
import { DEFAULT_LOCALE } from "../i18n";
import formatter from "../mixins/formatter";
import { CO2_TYPE } from "../units";
import PlanStartIcon from "./MaterialIcon/PlanStart.vue";
import ClimaterIcon from "./MaterialIcon/Climater.vue";
import PlanEndIcon from "./MaterialIcon/PlanEnd.vue";
import PlanStartIcon from "./MaterialIcon/PlanStart.vue";
import ReconnectIcon from "./MaterialIcon/Reconnect.vue";
import RfidWaitIcon from "./MaterialIcon/RfidWait.vue";
import ClimaterIcon from "./MaterialIcon/Climater.vue";
import VehicleLimitReachedIcon from "./MaterialIcon/VehicleLimitReached.vue";
import VehicleLimitWarningIcon from "./MaterialIcon/VehicleLimitWarning.vue";
import VehicleLimitIcon from "./MaterialIcon/VehicleLimit.vue";
import VehicleMinSocIcon from "./MaterialIcon/VehicleMinSoc.vue";
import SunDownIcon from "./MaterialIcon/SunDown.vue";
import SunUpIcon from "./MaterialIcon/SunUp.vue";
import Tooltip from "bootstrap/js/dist/tooltip";
import VehicleLimitIcon from "./MaterialIcon/VehicleLimit.vue";
import VehicleLimitReachedIcon from "./MaterialIcon/VehicleLimitReached.vue";
import VehicleLimitWarningIcon from "./MaterialIcon/VehicleLimitWarning.vue";
import VehicleMinSocIcon from "./MaterialIcon/VehicleMinSoc.vue";
import WelcomeIcon from "./MaterialIcon/Welcome.vue";
const REASON_AUTH = "waitingforauthorization";
const REASON_DISCONNECT = "disconnectrequired";
export default {
name: "VehicleStatus",
components: {
ClimaterIcon,
DynamicPriceIcon,
PlanStartIcon,
PlanEndIcon,
PlanStartIcon,
ReconnectIcon,
RfidWaitIcon,
ClimaterIcon,
VehicleLimitIcon,
VehicleMinSocIcon,
SunDownIcon,
SunUpIcon,
VehicleLimitIcon,
VehicleMinSocIcon,
WelcomeIcon,
},
mixins: [formatter],
props: {
vehicleSoc: Number,
charging: Boolean,
chargingPlanDisabled: Boolean,
chargerAwaitingAuthorization: Boolean,
chargerStatusReason: String,
connected: Boolean,
currency: String,
effectiveLimitSoc: Number,
Expand Down Expand Up @@ -222,6 +236,7 @@ export default {
smartCostTooltip: null,
vehicleLimitTooltip: null,
awaitingAuthorizationTooltip: null,
disconnectRequiredTooltip: null,
};
},
mounted() {
Expand All @@ -235,6 +250,7 @@ export default {
this.updateSmartCostTooltip();
this.updateVehicleLimitTooltip();
this.updateAwaitingAuthorizationTooltip();
this.updateDisconnectRequiredTooltip();
},
watch: {
planActiveTooltipContent() {
Expand Down Expand Up @@ -267,6 +283,9 @@ export default {
awaitingAuthorizationTooltipContent() {
this.$nextTick(this.updateAwaitingAuthorizationTooltip);
},
disconnectRequiredTooltipContent() {
this.$nextTick(this.updateDisconnectRequiredTooltip);
},
},
computed: {
phaseTimerActive() {
Expand Down Expand Up @@ -307,14 +326,23 @@ export default {
return this.connected && this.vehicleLimitSoc > 0 && this.vehicleLimitSoc < limit;
},
awaitingAuthorizationVisible() {
return this.chargerAwaitingAuthorization;
return this.chargerStatusReason === REASON_AUTH;
},
awaitingAuthorizationTooltipContent() {
if (!this.awaitingAuthorizationVisible) {
return "";
}
return this.$t("main.vehicleStatus.awaitingAuthorization");
},
disconnectRequiredVisible() {
return this.chargerStatusReason === REASON_DISCONNECT;
},
disconnectRequiredTooltipContent() {
if (!this.disconnectRequiredVisible) {
return "";
}
return this.$t("main.vehicleStatus.disconnectRequired");
},
vehicleLimitTooltipContent() {
if (!this.vehicleLimitVisible) {
return "";
Expand Down Expand Up @@ -584,6 +612,13 @@ export default {
this.$refs.awaitingAuthorization
);
},
updateDisconnectRequiredTooltip() {
this.updateTooltip(
this.disconnectRequiredTooltip,
this.disconnectRequiredTooltipContent,
this.$refs.disconnectRequired
);
},
updateTooltip: function (instance, content, ref, hoverOnly = false) {
if (!content || !ref) {
if (instance) {
Expand Down
13 changes: 12 additions & 1 deletion charger/ocpp.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,9 +342,20 @@ var _ api.StatusReasoner = (*OCPP)(nil)

func (c *OCPP) StatusReason() (api.Reason, error) {
var res api.Reason
if c.conn.NeedsAuthentication() {

s, err := c.conn.Status()
if err != nil {
return res, err
}

switch {
case c.conn.NeedsAuthentication():
res = api.ReasonWaitingForAuthorization

case s == core.ChargePointStatusFinishing:
res = api.ReasonDisconnectRequired
}

return res, nil
}

Expand Down
10 changes: 5 additions & 5 deletions core/keys/loadpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ const (
PhasesEnabled = "phasesEnabled" // enabled phases (1/3)
PhasesActive = "phasesActive" // active phases as used by vehicle (1/2/3)

ChargerIcon = "chargerIcon" // charger icon for ui
ChargerFeature = "chargerFeature" // charger feature
ChargerPhysicalPhases = "chargerPhysicalPhases" // charger phases
ChargerPhases1p3p = "chargerPhases1p3p" // phase switcher (1p3p chargers)
ChargerAwaitingAuthorization = "chargerAwaitingAuthorization" // charger awaiting authorization
ChargerIcon = "chargerIcon" // charger icon for ui
ChargerFeature = "chargerFeature" // charger feature
ChargerPhysicalPhases = "chargerPhysicalPhases" // charger phases
ChargerPhases1p3p = "chargerPhases1p3p" // phase switcher (1p3p chargers)
ChargerStatusReason = "chargerStatusReason" // either awaiting authorization or disconnect required

// loadpoint status
Enabled = "enabled" // loadpoint enabled
Expand Down
2 changes: 1 addition & 1 deletion core/loadpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -1676,7 +1676,7 @@ func (lp *Loadpoint) Update(sitePower float64, rates api.Rates, batteryBuffered,

if sr, ok := lp.charger.(api.StatusReasoner); ok && lp.GetStatus() == api.StatusB {
if r, err := sr.StatusReason(); err == nil {
lp.publish(keys.ChargerAwaitingAuthorization, r == api.ReasonWaitingForAuthorization)
lp.publish(keys.ChargerStatusReason, r)
} else {
lp.log.ERROR.Printf("charger status reason: %v", err)
}
Expand Down
1 change: 1 addition & 0 deletions i18n/de.toml
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,7 @@ cleanEnergyNextStart = "Saubere Energie in {duration}."
cleanEnergySet = "CO₂-Limit gesetzt."
climating = "Vorklimatisierung erkannt."
connected = "Verbunden."
disconnectRequired = "Vorgang abgebrochen. Erneut verbinden."
disconnected = "Nicht verbunden."
finished = "Abgeschlossen."
minCharge = "Mindestladung bis {soc}."
Expand Down
1 change: 1 addition & 0 deletions i18n/en.toml
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,7 @@ cleanEnergyNextStart = "Clean energy in {duration}."
cleanEnergySet = "CO₂ limit set."
climating = "Pre-conditioning detected."
connected = "Connected."
disconnectRequired = "Session terminated. Please reconnect."
disconnected = "Disconnected."
finished = "Finished."
minCharge = "Minimum charging to {soc}."
Expand Down

0 comments on commit d03705e

Please sign in to comment.