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

Some adjustments for status notification. #58

Merged
merged 1 commit into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion src/lib/ChargeStation/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ class Connection {
const promise = new Promise<void>((resolve, reject) => {
const timeoutId = setTimeout(() => {
this.inflight = undefined;
reject(new Error(`Call with message id ${messageId} timed out after ${this.inflightTimeoutMs / 1000} seconds`))
reject(new Error(`Call with message id ${messageId} timed out after ${this.inflightTimeoutMs / 1000} seconds`));
}, this.inflightTimeoutMs);

this.inflight = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ export default async function sendStatusNotificationPreparing({
chargepoint,
session,
}) {
if (chargepoint.currentStatus[session.connectorId] === 'Preparing') {
return;
}

await chargepoint.writeCall(
'StatusNotification',
{
Expand Down
4 changes: 4 additions & 0 deletions src/lib/ChargeStation/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,10 @@ export default class ChargeStation {
session,
};
}

sendStatusNotification(connectorId: number, status: string) {
this.writeCall('StatusNotification', { connectorId, status, errorCode: 'NoError', });
}
}

/*
Expand Down
4 changes: 1 addition & 3 deletions src/screens/Dashboard/StatusNotificationModal.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import React from 'react';
import { Modal, Button, Form, Header, Divider } from 'semantic';
import { Modal, Button, Form, Divider } from 'semantic';
import modal from 'helpers/modal';
import { sessionSettingsList } from 'lib/settings';
import { HelpTip } from 'components';

function selectDefaultConnector(availableConnectors) {
return ['1', '2'].filter((connectorId) => {
Expand Down
3 changes: 1 addition & 2 deletions src/screens/Dashboard/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,14 +243,13 @@ export default class Home extends React.Component {
currentStatus={chargeStation.currentStatus}
session={session}
onSave={async ({ connectorId, status }) => {
await chargeStation.sendStatusNotification(connectorId, status);
await chargeStation.sendStatusNotification(parseInt(connectorId), status);
this.nextTick();
}}
trigger={
<Button
inverted
primary={!!chargeStationIsCharging}
disabled={!chargeStationIsCharging}
icon="signal"
content="Status"
/>
Expand Down