Skip to content

Commit

Permalink
Merge pull request #58 from e-flux-platform/fix/some-adjustments
Browse files Browse the repository at this point in the history
Some adjustments for status notification.
  • Loading branch information
nick-jones authored Apr 4, 2024
2 parents 6de20ad + fb721e6 commit b75427b
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 6 deletions.
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

0 comments on commit b75427b

Please sign in to comment.