UNPKG

node-red-contrib-ocpp

Version:

A set of nodes to communicate via OCPP to a compatible charge box or central system

214 lines (195 loc) 9.94 kB
<style> .header { text-decoration: underline; font-weight: bold; margin-top: 5px; } .bordered { padding-left: 12px; padding-top: 4px; border: 1px solid lightgrey; box-sizing: border-box; } </style> <script type="text/javascript"> RED.nodes.registerType('CP client JSON', { category: 'OCPP', color: '#3FADB5', defaults: { name: {value: "", required: false}, cbId: {value: "", required: true}, remotecs: {value: "", type: "ocpp-remote-cs"}, ocppver: {value: "1.6j", required: true}, command: { value: "", required: false}, cmddata: { value: "", required: false}, log: { value: false, required: true }, pathlog: {value: "", required: false}, wsdelayconnect: {value: false, required: true}, wstomin: {value: 5, required: false}, wstomax: {value: 360, required: false}, wstoinc: {value: 5, required: false} }, inputs: 1, outputs: 1, icon: "file.jpg", label: function() { return this.name||this.cbId||"OCPP CP JSON"; }, oneditprepare: function() { var cblist = [ { cb: "#node-input-log", cont: "#containerlog" }, ] function updateHideContainer(checkbox,container){ if ($(checkbox).is(':checked')){ $(container).show(); } else{ $(container).hide(); } } cblist.forEach(x => { updateHideContainer(x.cb,x.cont); $(x.cb).on('click', function(){ updateHideContainer(x.cb,x.cont); }); }); } }); </script> <script type="text/javascript"> </script> <script type="text/x-red" data-template-name="CP client JSON"> <div class="form-row"> <label for="node-input-name"><i class="icon-tag"></i> Name</label> <input type="text" id="node-input-name" placeholder="Node Name" /> </div> <div class="form-row"> <label for="node-input-cbId"><i class="icon-tag"></i> cbId</label> <input type="text" id="node-input-cbId" placeholder="Unique Charge Box Identity" /> </div> <div class="form-row"> <label for="node-input-remotecs"><i class="icon-tag"></i> Central System</label> <input type="text" id="node-input-remotecs" placeholder="Setup" /> </div> <div class="form-row"> <label for="node-config-input-ocppver"><i class="icon-cog"></i> OCPP Ver</label> <select id="node-config-input-ocppver"> <option value="1.6j">1.6 JSON</option> </select> </div> <div class="form-row"> <input type="checkbox" id="node-input-wsdelayconnect" value="" style="display: inline-block; width: auto; vertical-align: top; margin-left: 30px; margin-right: 5px;"> <label for="node-input-wsdealyconnect" style="width: auto" >Delay connection on startup </label> </div> <div class="form-row"> <label for="node-input-command"><i class="icon-cog"></i> Command</label> <select id="node-input-command"> <option value="">&lt;None&gt;</option> <option value="Authorize">Authorize</option> <option value="BootNotification">Boot Notification</option> <option value="DataTransfer">Data Transfer</option> <option value="Diagnostics Status Notification">DiagnosticsStatusNotification</option> <option value="Firmware Status Notification">FirmwareStatusNotification</option> <option value="Heartbeat">Heartbeat</option> <option value="MeterValues">Meter Values</option> <option value="StartTransaction">Start Transaction</option> <option value="StatusNotification">Status Notification</option> <option value="StopTransaction">Stop Transaction</option> </select><br/> </div> <div class="form-row"> <label for="node-input-cmddata"><i class="icon-cog"></i> Command Params</label> <textarea rows="4" cols="50" id="node-input-cmddata" placeholder="JSON formatted parameters"></textarea> </div> <div class="header">Logging</div> <div class="bordered"> <div class="checkbox"> <label> <input type="checkbox" value="" id="node-input-log" onclick="toggleEnabled(this)"/> Logging Enabled </label> </div> <div id="containerlog" class="form-row"> <label for="node-input-pathlog" > <i class="icon-globe"></i> Path </label> <input type="text" id="node-input-pathlog" placeholder="log file path and name" /> </div> </div> <div class="header">Reconnect Rate</div> <div class="form-row"> <label for="node-input-wstomin"><i class="icon-timer"></i> Min (sec)</label> <input type="number" id="node-input-wstomin" min="0"> </div> <div class="form-row"> <label for="node-input-wstomax"><i class="icon-timer"></i> Max (sec)</label> <input type="number" id="node-input-wstomax" min="0"> </div> <div class="form-row"> <label for="node-input-wstoinc"><i class="icon-timer"></i> Inc (sec)</label> <input type="number" id="node-input-wstoinc" min="0"> </div> </script> <script type="text/x-red" data-help-name="CP client JSON"> <p>Acts as an OCPP JSON ChargePoint</p> <h3>Configuration Settings</h3> <dl> <dt>cbId</dt> <dd>A unique name / identifier for this charge point</dd> <dt>Central System</dt> <dd>The URL of the Central System this charge point communicates with</dd> <dt>OCPP Ver</dt> <dd><i>*Future use<br/>Currently defaults to OCPP JSON 1.6 only</i></dd> <dt>Delay connection on startup</dt> <dd>If checked the websocket connection to the CS (CSMS) is not immediately attempted when the flow is started. Instead a message type "99" and command of "connect" must be sent to the node to initiate a connection</dd> <dt>Command:</i></dt> <dd>(Optional) Select an OCPP command to send if none is passed in via <code>msg.payload.command</code></dd> <dt>Command Params:</dt> <dd>(Optional) OCPP command data object to send if none is passed in via <code>msg.payload.data</code>. Must be JSON formatted</dd> <dt>logging enabled</dt> <dd>enables/disables logging for this node</dd> <dt>Path</dt> <dd>Path to file used for logging. Required if "logging enabled" is checked, otherwise logging will be disabled at runtime</dd> <dt>Name:</dt> <dd>The name shown on the workspace</dd> <dt>Reconnect Rate: Min</dt> <dd>How many seconds the node waits to try to reconnect the first time after it is closed</dd> <dt>Reconnect Rate: Max</dt> <dd>The maximum number of seconds the node waits before trying a reconnect<dd> <dt>Reconnect Rate: Inc</dt> <dd>The increment in seconds that is added to the retry delay (from min to max) for each reconnect try<dd> </dl> <h3>Inputs</h3> <dl class="message-properties"> <dt><code>msg.payload.MessageId</code>&nbsp;<i>optional</i> &nbsp;<span class="property-type">string</span></dt> <dd>Unique identifier for the message. This should only be used for originating calls/requests and not for responses. By default if this parameter is missing a unique identifier will be assigned by the node</dd> <dt><code>msg.payload.msgType</code>&nbsp;<i>optional</i> &nbsp;<span class="property-type">number</span></dt> <dd><ul> <li>2 (default) for a CALL/Request to the CSMS. <li>3 for sending an OCPP message response. <li>99 for special non-ocpp commands such as (re)connecting or closing of the websocket connection. </ul> <dd> <dt><code>msg.payload.command</code>&nbsp;<i>optional</i> &nbsp;<span class="property-type">string</span></dt> <dd>OCPP request (eg: "BootNotification") being sent to the Central System (if msgType is 2), otherwise if msgType is 99 allows for <strong>"connect"</strong> and <strong>"close"</strong> commands to (re)connect / close the websocket connection. <i>(experimental)</i> <strong>"ws_state"</strong> command to output the ONLINE/OFFLINE status of the node.</dd> <dt><code>msg.payload.data</code>&nbsp;<i>optional</i>&nbsp;<span class="property-type">object</span></dt> <dd>Object containing parameters for the command. In the case of msgType 99, an optional "cbId" and "csmsUrl" can be passed in to set/change the chargeBoxId and websocket URL.</dd> </dl> <h3>Outputs</h3> <dl class="messge-properties"> <dt>ocpp <span class="property-type">object</dt> <dd><code>msg.ocpp</code> object containing ocpp related information <ul> <li><code>MessageId</code>: the unique message identifier</li> <li>msgType</code>: 2 = CALL/Request, 3= CALLRESPONSE/Reply/response</li> <li><code>command</code>: the request command sent</li> <li><code>data</code>: object containing the parameters passed to the EVSE for the request (if any)</li> </ul> </dd> <dt>payload <span class="property-type">object</dt> <dd><code>msg.payload</code> object containing response data sent back from the Central System. Contents vary depending on the request command. </dd> </dl> </script>