You need to install node-red-contrib-ocpp into node-red. my Flow feeds a general generic kwh device in domoticz and sends various status notifications.
the data entered into the OCPP SOAP node (especially url and port) needs to match the supervision settings in your box. if all goes well, you should begin to receive heartbeat messages immediately. Authentication in my case is done by the wallbox itself via NFC. I'm using a NFC enabled ring for that.
the node block you will see under the main which is labeled 'send request....' is optional for testing etc and not required for proper function.
Code: Select all
[{"id":"565e40f1.7128c","type":"tab","label":"TBAWB1","disabled":false,"info":""},{"id":"e1387a97.82a408","type":"CS server","z":"565e40f1.7128c","name":"home@8834","port":"8834","enabled15":true,"path15":"/ocpp15s","enabled16":true,"path16":"/ocpp16s","enabled16j":true,"path16j":"/ocpp","log":true,"pathlog":"OCPP__.log","x":110,"y":130,"wires":[["10a08593.baab0a","785b602f.5745d"]]},{"id":"785b602f.5745d","type":"debug","z":"565e40f1.7128c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":110,"y":220,"wires":[]},{"id":"10a08593.baab0a","type":"switch","z":"565e40f1.7128c","name":"OCPP CS Command Switch","property":"payload.command","propertyType":"msg","rules":[{"t":"eq","v":"BootNotification","vt":"str"},{"t":"eq","v":"Authorize","vt":"str"},{"t":"eq","v":"Heartbeat","vt":"str"},{"t":"eq","v":"StatusNotification","vt":"str"},{"t":"eq","v":"MeterValues","vt":"str"},{"t":"eq","v":"StartTransaction","vt":"str"},{"t":"eq","v":"StopTransaction","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":8,"x":399,"y":135,"wires":[["812bd24c.a3b4c"],["2ad7f2a5.e8db9e","a204682d.55a848"],["276b8fd7.55862"],["80bc0d1a.80316","cac3aec1.85452"],["80bc0d1a.80316","cac3aec1.85452","3d936649.5b772a","3cbe14f6.57d63c","a204682d.55a848","1bdb49c9.c2d0a6"],["936009ae.e127a8","cac3aec1.85452","a204682d.55a848","192f241f.58202c","6ba40cb3.3142c4"],["cac3aec1.85452","2ad7f2a5.e8db9e","5f35989b.9d5f58","a204682d.55a848","4a0ec78c.858568","5a90af71.fa3aa"],["cac3aec1.85452"]]},{"id":"c571ba35.be3818","type":"server response","z":"565e40f1.7128c","name":"","x":1520,"y":140,"wires":[]},{"id":"812bd24c.a3b4c","type":"function","z":"565e40f1.7128c","name":"BootNotification","func":"msg.payload = {\n interval: 120,\n currentTime: new Date().toISOString(),\n status: \"Accepted\"\n}\nreturn msg;","outputs":1,"noerr":0,"x":1019,"y":36,"wires":[["c571ba35.be3818"]]},{"id":"936009ae.e127a8","type":"function","z":"565e40f1.7128c","name":"Start Transaction","func":"msg.payload = {\n idTagInfo: {\n status: \"Accepted\",\n },\n transactionId: getRndInteger(0,100000)\n}\nreturn msg;\n\nfunction getRndInteger(min, max) {\n return Math.floor(Math.random() * (max - min + 1) ) + min;\n}\n","outputs":1,"noerr":0,"x":1029,"y":216,"wires":[["c571ba35.be3818"]]},{"id":"5f35989b.9d5f58","type":"function","z":"565e40f1.7128c","name":"Stop Transaction","func":"msg.payload = { idTagInfo: { status: \"Accepted\"} };\nreturn msg;","outputs":1,"noerr":0,"x":1250,"y":240,"wires":[["c571ba35.be3818"]]},{"id":"276b8fd7.55862","type":"change","z":"565e40f1.7128c","name":"Heartbeat","rules":[{"t":"set","p":"payload","pt":"msg","to":"{}","tot":"json"},{"t":"set","p":"payload.currentTime","pt":"msg","to":"$now()","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":999,"y":114,"wires":[["c571ba35.be3818"]]},{"id":"2ad7f2a5.e8db9e","type":"change","z":"565e40f1.7128c","name":"Generic Status=Accepted","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"idTagInfo\":{\"status\":\"Accepted\"}}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":1049,"y":76,"wires":[["c571ba35.be3818","7be71ba6.bc4384"]]},{"id":"80bc0d1a.80316","type":"change","z":"565e40f1.7128c","name":"Generic Return","rules":[{"t":"set","p":"ocpp.data","pt":"msg","to":"payload.data","tot":"msg"},{"t":"set","p":"payload","pt":"msg","to":"{}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":1019,"y":156,"wires":[["c571ba35.be3818"]]},{"id":"cac3aec1.85452","type":"debug","z":"565e40f1.7128c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":530,"y":270,"wires":[]},{"id":"6238f451.2cac0c","type":"inject","z":"565e40f1.7128c","name":"get hb","props":[{"p":"payload","v":"{\"command\":\"GetConfiguration\",\"data\":{\"key\":[\"HeartbeatInterval\"]}}","vt":"json"},{"p":"topic","v":"","vt":"string"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"command\":\"GetConfiguration\",\"data\":{\"key\":[\"HeartbeatInterval\"]}}","payloadType":"json","x":150,"y":720,"wires":[["7ff476fe.321538"]]},{"id":"7be71ba6.bc4384","type":"debug","z":"565e40f1.7128c","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":1249,"y":56,"wires":[]},{"id":"3d936649.5b772a","type":"debug","z":"565e40f1.7128c","name":"MeterValues","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1090,"y":280,"wires":[]},{"id":"3cbe14f6.57d63c","type":"debug","z":"565e40f1.7128c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":750,"y":350,"wires":[]},{"id":"7ff476fe.321538","type":"CS request JSON","z":"565e40f1.7128c","name":"CS TBAWB1","remotecb":"6b44327e.3af84c","command":"GetConfiguration","cmddata":"","log":true,"pathlog":"","x":410,"y":710,"wires":[["d10cef24.bc4c3"]]},{"id":"d10cef24.bc4c3","type":"debug","z":"565e40f1.7128c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":620,"y":730,"wires":[]},{"id":"b469a8e4.5bce28","type":"comment","z":"565e40f1.7128c","name":"Basic OCPP Central System Server and supporting nodes","info":"Change the port address and paths to meet your needs.\nThis is a very basic (does represent a fully functional CS) example","x":230,"y":30,"wires":[]},{"id":"7ab36f84.9f532","type":"comment","z":"565e40f1.7128c","name":"Send request from the Central Server to Charge Point","info":"","x":250,"y":640,"wires":[]},{"id":"da309c0c.bd4f1","type":"comment","z":"565e40f1.7128c","name":"Inject a command with data","info":"","x":190,"y":680,"wires":[]},{"id":"bfc38ab.57fba78","type":"comment","z":"565e40f1.7128c","name":"Debug all incoming msgs","info":"","x":110,"y":260,"wires":[]},{"id":"170df296.c98d5d","type":"CS request JSON","z":"565e40f1.7128c","name":"CS TBAWB1 Change hb interval","remotecb":"6b44327e.3af84c","command":"ChangeConfiguration","cmddata":"{\n \"key\": \"HeartbeatInterval\",\n \"value\": \"1800\" \n}\n","log":true,"pathlog":"","x":480,"y":790,"wires":[["d10cef24.bc4c3"]]},{"id":"74f080cb.5d983","type":"inject","z":"565e40f1.7128c","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":160,"y":790,"wires":[["170df296.c98d5d"]]},{"id":"a204682d.55a848","type":"file","z":"565e40f1.7128c","name":"","filename":"wb_log.txt","appendNewline":true,"createDir":false,"overwriteFile":"false","encoding":"none","x":1620,"y":200,"wires":[[]]},{"id":"33ba103e.b1582","type":"CS request JSON","z":"565e40f1.7128c","name":"CS TBAWB1 Change hb interval","remotecb":"6b44327e.3af84c","command":"TriggerMessage","cmddata":"{\n \"requestedMessage\": \"MeterValues\"\n}\n","log":true,"pathlog":"","x":480,"y":850,"wires":[["d10cef24.bc4c3"]]},{"id":"4a66d315.d4499c","type":"inject","z":"565e40f1.7128c","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":160,"y":870,"wires":[["33ba103e.b1582"]]},{"id":"b7f22c41.5740f","type":"CS request JSON","z":"565e40f1.7128c","name":"CS TBAWB1","remotecb":"6b44327e.3af84c","command":"GetConfiguration","cmddata":"{}","log":true,"pathlog":"","x":420,"y":930,"wires":[["d10cef24.bc4c3"]]},{"id":"1e6bf7ca.45e638","type":"inject","z":"565e40f1.7128c","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":150,"y":930,"wires":[["b7f22c41.5740f"]]},{"id":"192f241f.58202c","type":"function","z":"565e40f1.7128c","name":"Start Transaction","func":"\nmsg.payload = {\n\n \"idx\" : 444,\n \"nvalue\" :0,\n \"svalue\" :\"10000;0\"\n \n}\nflow.set(\"prevEnergy\", 0)\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":980,"y":480,"wires":[["3f9fb1cb.924d5e"]]},{"id":"3f9fb1cb.924d5e","type":"mqtt out","z":"565e40f1.7128c","name":"","topic":"domoticz/in","qos":"","retain":"","broker":"5660e74b.bef428","x":1370,"y":480,"wires":[]},{"id":"1bdb49c9.c2d0a6","type":"function","z":"565e40f1.7128c","name":"Meter Values","func":"//every 15 minutes\nvar prevEnergy = flow.get(\"prevEnergy\")\nvar power = (parseInt(msg.payload.data.meterValue[0].sampledValue[0].value) - prevEnergy) * 4\nvar energy = parseInt(msg.payload.data.meterValue[0].sampledValue[0].value)\n\nvar newmsg = {payload:\"\", topic:\"\"};\nnewmsg.payload = { \n \"idx\" :444,\n \"nvalue\" :0,\n \"svalue\" :power.toString()+ \";\" + energy.toString()\n \n}\n\nflow.set(\"prevEnergy\", energy)\nreturn newmsg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":970,"y":680,"wires":[["3f9fb1cb.924d5e"]]},{"id":"4a0ec78c.858568","type":"function","z":"565e40f1.7128c","name":"Stop Transaction","func":"msg.payload = { \n \"idx\" :444,\n \"nvalue\" :0,\n \"svalue\" :\"0;\" + msg.payload.data.meterStop.toString()\n \n}\nflow.set(\"prevEnergy\", 0)\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":990,"y":580,"wires":[["3f9fb1cb.924d5e"]]},{"id":"6ba40cb3.3142c4","type":"function","z":"565e40f1.7128c","name":"msg Start","func":"msg.payload =\n{\n \"command\": \"sendnotification\",\n \"subject\": \"TBAWB1\",\n \"body\": \"Charging started\",\n \"priority\": 0\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":960,"y":400,"wires":[["3f9fb1cb.924d5e"]]},{"id":"5a90af71.fa3aa","type":"function","z":"565e40f1.7128c","name":"msg Stop","func":"\nvar energy = parseInt(msg.payload.meterStop) /1000\nmsg.payload =\n{\n \"command\": \"sendnotification\",\n \"subject\": \"TBAWB1\",\n \"body\": \"Charging stopped\" + \" \" + energy.toString() + \"KW charged\",\n \"priority\": 0\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":960,"y":620,"wires":[["3f9fb1cb.924d5e"]]},{"id":"27be44e6.947e3c","type":"inject","z":"565e40f1.7128c","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"command\":\"StopTransaction\",\"data\":{\"meterStop\":21874,\"timestamp\":\"2021-02-07T09:43:35Z\",\"transactionId\":48949}}","payloadType":"json","x":520,"y":460,"wires":[["36ef85b5.6a381a","4a0ec78c.858568"]]},{"id":"36ef85b5.6a381a","type":"debug","z":"565e40f1.7128c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":980,"y":780,"wires":[]},{"id":"6b44327e.3af84c","type":"ocpp-remotej-cp","name":"","cbId":"TBAWB1","ocppver":"1.6j"},{"id":"5660e74b.bef428","type":"mqtt-broker","name":"Controlberry","broker":"192.168.2.40","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]