Kostal Enector Wallbox mode maintained from home assistant

Hehe,
yea I am loving it! Works just perfect. I can do automations triggered by the battery level of my car now. AWESOME!
Is there a way to show the current kostal charging mode? For example if my wife switches it via the kostal Web Interface.
Thanks again. Loving it!

If I got it correctly you want to read the current ActiveChargeMode.
Yes you can poll frequently the state.

It is allready part of the nodes above:

[{"id":"73ce9212b81f3379","type":"http request","z":"cf9db411ca071c46","name":"http request GET","method":"GET","ret":"obj","paytoqs":"ignore","url":"http://192.168.178.161/api/e-mobility/config/chargemode","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[{"keyType":"other","keyValue":"Authorization","valueType":"msg","valueValue":"bearer"}],"x":890,"y":1020,"wires":[["af4da4c66b94f9c8","d922837769ba1bcc"]]},{"id":"af4da4c66b94f9c8","type":"debug","z":"cf9db411ca071c46","name":"state reached","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1160,"y":1020,"wires":[]},{"id":"3da08757f403f1f9","type":"http request","z":"cf9db411ca071c46","name":"http request PUT","method":"PUT","ret":"obj","paytoqs":"ignore","url":"http://192.168.178.161/api/e-mobility/config/chargemode","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[{"keyType":"other","keyValue":"Authorization","valueType":"msg","valueValue":"bearer"}],"x":630,"y":1020,"wires":[["73ce9212b81f3379","9f8bb0b07fae6721"]]},{"id":"3882f4f45550bff1","type":"inject","z":"cf9db411ca071c46","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"mode\":\"grid\", \"mincharginpowerquota\": 0, \"minpvpowerquota\": 100}","payloadType":"json","x":190,"y":900,"wires":[["3da08757f403f1f9"]]},{"id":"6f5f9d3707cc17c5","type":"trigger-state","z":"cf9db411ca071c46","name":"Wallbox ActiveChargeMode","server":"ba0f7c7d.deae9","version":5,"inputs":0,"outputs":3,"exposeAsEntityConfig":"","entities":{"entity":["input_select.wallbox_activechargemode"],"substring":[],"regex":[]},"debugEnabled":false,"constraints":[],"customOutputs":[{"messageType":"default","messageValue":"","messageValueType":"json","comparatorPropertyType":"always","comparatorPropertyValue":"","comparatorType":"is","comparatorValue":"","comparatorValueDataType":"str"}],"outputInitially":false,"stateType":"str","enableInput":false,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"x":140,"y":1020,"wires":[["a7046d486f71bf95"],[],[]]},{"id":"a7046d486f71bf95","type":"function","z":"cf9db411ca071c46","name":"mode parser","func":"var msg1 = { payload: { \"mode\": 0, \"bearer\":0 } }\nvar SelectedMode = msg.payload\nvar mode\nif (SelectedMode === \"Lock Mode\") {\n    mode = '{ \"mode\": \"lock\", \"mincharginpowerquota\": 0, \"minpvpowerquota\": 100 }';\n}\nelse if (SelectedMode === \"Power Mode\") {\n    mode ='{ \"mode\": \"grid\", \"mincharginpowerquota\": 0, \"minpvpowerquota\": 100 }';\n}\nelse if (SelectedMode === \"Solar Pure Mode\") {\n    mode = '{ \"mode\": \"pv\", \"mincharginpowerquota\": 0, \"minpvpowerquota\": 100 }';\n\n}\nelse if (SelectedMode === \"Solar Plus Mode\") {\n    mode = '{ \"mode\": \"hybrid\", \"mincharginpowerquota\": 0, \"minpvpowerquota\": 100 }';\n\n}\n\nmsg1.payload = mode;\nmsg1.bearer = global.get(\"Kostal_bearer\") ;\nreturn msg1;","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":410,"y":1020,"wires":[["3da08757f403f1f9"]]},{"id":"9f8bb0b07fae6721","type":"debug","z":"cf9db411ca071c46","name":"state reached","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1000,"y":900,"wires":[]},{"id":"1c2c32c88581c620","type":"inject","z":"cf9db411ca071c46","name":"","props":[],"repeat":"5","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":550,"y":920,"wires":[["63c0a7846f0d9def"]]},{"id":"25ef1c9c74581477","type":"ha-api","z":"cf9db411ca071c46","name":"sensor","server":"541ade28.b4a62","version":1,"debugenabled":false,"protocol":"http","method":"post","path":"/api/states/{{entity_id}}","data":"","dataType":"json","responseType":"json","outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"results"}],"x":1430,"y":960,"wires":[[]]},{"id":"63c0a7846f0d9def","type":"function","z":"cf9db411ca071c46","name":"bearer","func":"var msg1 = { payload: { \"mode\": 0, \"bearer\":0 } }\nmsg1.bearer = global.get(\"Kostal_bearer\") ;\nreturn msg1;","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":730,"y":940,"wires":[["73ce9212b81f3379"]]},{"id":"d922837769ba1bcc","type":"function","z":"cf9db411ca071c46","name":"updateSensor","func":"var msg1={};\n\nmsg1.entity_id = `sensor.Wallbox_CurrentActiveChargeMode`;\n\nmsg1.payload = {\n    data: {\n        state: msg.payload.mode,\n        attributes: {\n            'name': 'Wallbox_CurrentActiveChargeMode',\n            friendly_name: 'Wallbox_CurrentActiveChargeMode',\n            icon: 'mdi:pulse'\n        }\n    }\n};\n\nreturn msg1;\n\n","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":1200,"y":960,"wires":[["25ef1c9c74581477"]]},{"id":"ba0f7c7d.deae9","type":"server","name":"Home Assistant","version":5,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":false,"cacheJson":true,"heartbeat":false,"heartbeatInterval":"30","areaSelector":"friendlyName","deviceSelector":"friendlyName","entitySelector":"friendlyName","statusSeparator":"at: ","statusYear":"hidden","statusMonth":"short","statusDay":"numeric","statusHourCycle":"h23","statusTimeFormat":"h:m","enableGlobalContextStore":true},{"id":"541ade28.b4a62","type":"server","name":"Home Assistant","version":5,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"","connectionDelay":false,"cacheJson":false,"heartbeat":false,"heartbeatInterval":"","areaSelector":"friendlyName","deviceSelector":"friendlyName","entitySelector":"friendlyName","statusSeparator":"at: ","statusYear":"numeric","statusMonth":"2-digit","statusDay":"2-digit","statusHourCycle":"h23","statusTimeFormat":"h:m","enableGlobalContextStore":true}]

Give it a try.
The 2nd inject mode polls every 5s the current state ActiveChargeMode and places the result in a sensor named sensor.CurrentActiveChargeMode.

Hope this helps!

lars

Again, worked perfectly. You such a legend. Much appreciated :))

No need to answer bc thats just details. But would it be possible to show the correct active charging mode (for example lock) also in the dropdown menu for the “wallbox_active charge mode”. Right now the status could be “Lock” (if chosen via kostal app). The sensor would also show “Lock” then but the dropdown menu for choosing the charging mode would not change.
Hopefully it is understandable.

Give it a try!

[{"id":"1c2c32c88581c620","type":"inject","z":"cf9db411ca071c46","name":"","props":[],"repeat":"5","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":550,"y":920,"wires":[["63c0a7846f0d9def"]]},{"id":"63c0a7846f0d9def","type":"function","z":"cf9db411ca071c46","name":"bearer","func":"var msg1 = { payload: { \"mode\": 0, \"bearer\":0 } }\nmsg1.bearer = global.get(\"Kostal_bearer\") ;\nreturn msg1;","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":730,"y":940,"wires":[["73ce9212b81f3379"]]},{"id":"73ce9212b81f3379","type":"http request","z":"cf9db411ca071c46","name":"http request GET","method":"GET","ret":"obj","paytoqs":"ignore","url":"http://192.168.178.161/api/e-mobility/config/chargemode","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[{"keyType":"other","keyValue":"Authorization","valueType":"msg","valueValue":"bearer"}],"x":890,"y":1020,"wires":[["af4da4c66b94f9c8","d922837769ba1bcc","9b7f04539fb8c74b"]]},{"id":"3da08757f403f1f9","type":"http request","z":"cf9db411ca071c46","name":"http request PUT","method":"PUT","ret":"obj","paytoqs":"ignore","url":"http://192.168.178.161/api/e-mobility/config/chargemode","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[{"keyType":"other","keyValue":"Authorization","valueType":"msg","valueValue":"bearer"}],"x":630,"y":1020,"wires":[["73ce9212b81f3379","9f8bb0b07fae6721"]]},{"id":"af4da4c66b94f9c8","type":"debug","z":"cf9db411ca071c46","name":"state reached","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1160,"y":1020,"wires":[]},{"id":"d922837769ba1bcc","type":"function","z":"cf9db411ca071c46","name":"updateSensor","func":"var msg1={};\n\nmsg1.entity_id = `sensor.Wallbox_CurrentActiveChargeMode`;\n\nmsg1.payload = {\n    data: {\n        state: msg.payload.mode,\n        attributes: {\n            'name': 'Wallbox_CurrentActiveChargeMode',\n            friendly_name: 'Wallbox_CurrentActiveChargeMode',\n            icon: 'mdi:pulse'\n        }\n    }\n};\n\nreturn msg1;\n\n","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":1200,"y":960,"wires":[["25ef1c9c74581477"]]},{"id":"9b7f04539fb8c74b","type":"function","z":"cf9db411ca071c46","name":"updatedropdown","func":"var msg1={};\n\n\n\nmsg1.payload = {\n    \"option\": msg.payload.mode\n};\n\n\n// msg.payload = {\n//     domain: \"light\",\n//     service: \"turn_off\",\n//     data: {\n//         entity_id: [grupo],\n//     }\n// };\n\nreturn msg1;\n\n","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":1230,"y":900,"wires":[["337d69047b0532b5","f9607479d9b41f71"]]},{"id":"3882f4f45550bff1","type":"inject","z":"cf9db411ca071c46","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"mode\":\"grid\", \"mincharginpowerquota\": 0, \"minpvpowerquota\": 100}","payloadType":"json","x":190,"y":900,"wires":[["3da08757f403f1f9"]]},{"id":"a7046d486f71bf95","type":"function","z":"cf9db411ca071c46","name":"mode parser","func":"var msg1 = { payload: { \"mode\": 0, \"bearer\":0 } }\nvar SelectedMode = msg.payload\nvar mode\nif (SelectedMode === \"lock\") {\n    mode = '{ \"mode\": \"lock\", \"mincharginpowerquota\": 0, \"minpvpowerquota\": 100 }';\n}\nelse if (SelectedMode === \"grid\") {\n    mode ='{ \"mode\": \"grid\", \"mincharginpowerquota\": 0, \"minpvpowerquota\": 100 }';\n}\nelse if (SelectedMode === \"pv\") {\n    mode = '{ \"mode\": \"pv\", \"mincharginpowerquota\": 0, \"minpvpowerquota\": 100 }';\n\n}\nelse if (SelectedMode === \"hybrid\") {\n    mode = '{ \"mode\": \"hybrid\", \"mincharginpowerquota\": 0, \"minpvpowerquota\": 100 }';\n\n}\n\nmsg1.payload = mode;\nmsg1.bearer = global.get(\"Kostal_bearer\") ;\nreturn msg1;","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":410,"y":1020,"wires":[["3da08757f403f1f9"]]},{"id":"9f8bb0b07fae6721","type":"debug","z":"cf9db411ca071c46","name":"state reached","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1000,"y":900,"wires":[]},{"id":"25ef1c9c74581477","type":"ha-api","z":"cf9db411ca071c46","name":"sensor","server":"541ade28.b4a62","version":1,"debugenabled":false,"protocol":"http","method":"post","path":"/api/states/{{entity_id}}","data":"","dataType":"json","responseType":"json","outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"results"}],"x":1430,"y":960,"wires":[[]]},{"id":"337d69047b0532b5","type":"api-call-service","z":"cf9db411ca071c46","name":"input_select_Wallbox_ActiveChargeMode","server":"ba0f7c7d.deae9","version":7,"debugenabled":false,"action":"input_select.select_option","floorId":[],"areaId":[],"deviceId":[],"entityId":["input_select.wallbox_activechargemode"],"labelId":[],"data":"{\"option\":$join(payload.option,\",\")}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","blockInputOverrides":true,"domain":"input_select","service":"select_option","x":1560,"y":900,"wires":[[]]},{"id":"f9607479d9b41f71","type":"debug","z":"cf9db411ca071c46","name":"state reached","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1453.0435791015625,"y":828.0435180664062,"wires":[]},{"id":"6f5f9d3707cc17c5","type":"trigger-state","z":"cf9db411ca071c46","name":"Wallbox ActiveChargeMode","server":"ba0f7c7d.deae9","version":5,"inputs":0,"outputs":3,"exposeAsEntityConfig":"","entities":{"entity":["input_select.wallbox_activechargemode"],"substring":[],"regex":[]},"debugEnabled":false,"constraints":[],"customOutputs":[{"messageType":"default","messageValue":"","messageValueType":"json","comparatorPropertyType":"always","comparatorPropertyValue":"","comparatorType":"is","comparatorValue":"","comparatorValueDataType":"str"}],"outputInitially":false,"stateType":"str","enableInput":false,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"x":140,"y":1020,"wires":[["a7046d486f71bf95"],[],[]]},{"id":"541ade28.b4a62","type":"server","name":"Home Assistant","version":5,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"","connectionDelay":false,"cacheJson":false,"heartbeat":false,"heartbeatInterval":"","areaSelector":"friendlyName","deviceSelector":"friendlyName","entitySelector":"friendlyName","statusSeparator":"at: ","statusYear":"numeric","statusMonth":"2-digit","statusDay":"2-digit","statusHourCycle":"h23","statusTimeFormat":"h:m","enableGlobalContextStore":true},{"id":"ba0f7c7d.deae9","type":"server","name":"Home Assistant","version":5,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":false,"cacheJson":true,"heartbeat":false,"heartbeatInterval":"30","areaSelector":"friendlyName","deviceSelector":"friendlyName","entitySelector":"friendlyName","statusSeparator":"at: ","statusYear":"hidden","statusMonth":"short","statusDay":"numeric","statusHourCycle":"h23","statusTimeFormat":"h:m","enableGlobalContextStore":true}]

If ok, you can think about not using the sensor anymore!

BR,
Lars

It gives me an error.
Any chance to tip you by the way? :star_struck:

Hi,
could you share the debug results?
Lars

Thx. Using the debug mode helped. Had to rename the helpers to grid, pv, lock, hybrid.
Now it is working :)))
Any chance for a tip if it is not against the policy of the forum. You have been amazing.