Kostal Piko MP integration via XML parsing

Ok, here’s the thing. We’ve got a Kostal Piko MP 2.5 in our home with an old firmware. That’s the one where you don’t even have a JSON transfer between the onboard server and their UI. It uses XML to transfer the data.

Since I haven’t found any integration that was able to use the data, I build myself a solution last night that maybe other people with the same “firmware problem” like to see and use as well. It uses Node Red and the Node Red Companion integration to create sensors in Home Assistant. So if Node Red isn’t your thing, you’re still out of luck (maybe I’ll have a look if I can create an automation later that will do the same thing).

This is what it looks like in Node Red:

Here’s the exported code:

[{"id":"3cbe165a.88148a","type":"http request","z":"51ab8a82.65a544","name":"","method":"GET","ret":"txt","paytoqs":"query","url":"http://192.168.1.90/measurements.xml?{{timestamp}}","tls":"","persist":false,"proxy":"","authType":"","x":430,"y":680,"wires":[["e7ed6408.fa2b78"]]},{"id":"d1e7a9d6.0d33a8","type":"inject","z":"51ab8a82.65a544","name":"Get timestamp every 10 seconds","props":[{"p":"timestamp","v":"","vt":"date"},{"p":"topic","vt":"str"}],"repeat":"10","crontab":"","once":false,"onceDelay":"","topic":"","x":180,"y":680,"wires":[["3cbe165a.88148a"]]},{"id":"e7ed6408.fa2b78","type":"xml","z":"51ab8a82.65a544","name":"","property":"payload","attr":"","chr":"","x":590,"y":680,"wires":[["a4f02634.e63dd8","808fe177.e5d7b","59f9b8d2.fce4c8","e0a8aa72.60d4c8","da9d7b88.7564b8","33b002fe.33b9ae","4381d510.5c271c","9df0ab72.82c958","acdefcf2.2745d"]]},{"id":"28047e4f.994d82","type":"ha-entity","z":"51ab8a82.65a544","name":"AC Voltage Sensor","server":"1d3ab900.3ac2d7","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"kostal_piko_ac_voltage"},{"property":"device_class","value":"voltage"},{"property":"icon","value":""},{"property":"unit_of_measurement","value":"V"}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":1130,"y":440,"wires":[[]]},{"id":"a4f02634.e63dd8","type":"template","z":"51ab8a82.65a544","name":"DC Voltage Value","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{{payload.root.Device.0.Measurements.0.Measurement.4.$.Value}}","output":"str","x":870,"y":680,"wires":[["ddd0572.e1654a8"]]},{"id":"808fe177.e5d7b","type":"template","z":"51ab8a82.65a544","name":"AC Voltage Value","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{{payload.root.Device.0.Measurements.0.Measurement.0.$.Value}}","output":"str","x":870,"y":440,"wires":[["28047e4f.994d82"]]},{"id":"ddd0572.e1654a8","type":"ha-entity","z":"51ab8a82.65a544","name":"DC Voltage Sensor","server":"1d3ab900.3ac2d7","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"kostal_piko_dc_voltage"},{"property":"device_class","value":"voltage"},{"property":"icon","value":""},{"property":"unit_of_measurement","value":"V"}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":1130,"y":680,"wires":[[]]},{"id":"59f9b8d2.fce4c8","type":"template","z":"51ab8a82.65a544","name":"DC Current Value","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{{payload.root.Device.0.Measurements.0.Measurement.5.$.Value}}","output":"str","x":870,"y":740,"wires":[["43ebd78a.6a0208"]]},{"id":"43ebd78a.6a0208","type":"ha-entity","z":"51ab8a82.65a544","name":"DC Current Sensor","server":"1d3ab900.3ac2d7","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"kostal_piko_dc_current"},{"property":"device_class","value":"current"},{"property":"icon","value":""},{"property":"unit_of_measurement","value":"A"}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":1130,"y":740,"wires":[[]]},{"id":"c66cf68e.8e66d8","type":"ha-entity","z":"51ab8a82.65a544","name":"AC Current Sensor","server":"1d3ab900.3ac2d7","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"kostal_piko_ac_current"},{"property":"device_class","value":"current"},{"property":"icon","value":""},{"property":"unit_of_measurement","value":"A"}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":1130,"y":500,"wires":[[]]},{"id":"e0a8aa72.60d4c8","type":"template","z":"51ab8a82.65a544","name":"AC Current Value","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{{payload.root.Device.0.Measurements.0.Measurement.1.$.Value}}","output":"str","x":870,"y":500,"wires":[["c66cf68e.8e66d8"]]},{"id":"7e2c396.febd6c8","type":"ha-entity","z":"51ab8a82.65a544","name":"AC Power Sensor","server":"1d3ab900.3ac2d7","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"kostal_piko_ac_power"},{"property":"device_class","value":"power"},{"property":"icon","value":""},{"property":"unit_of_measurement","value":"W"}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":1130,"y":560,"wires":[[]]},{"id":"da9d7b88.7564b8","type":"template","z":"51ab8a82.65a544","name":"AC Power Value","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{{payload.root.Device.0.Measurements.0.Measurement.2.$.Value}}","output":"str","x":860,"y":560,"wires":[["7e2c396.febd6c8"]]},{"id":"8a2d5941.1baac8","type":"ha-entity","z":"51ab8a82.65a544","name":"AC Frequency Sensor","server":"1d3ab900.3ac2d7","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"kostal_piko_ac_frequency"},{"property":"device_class","value":""},{"property":"icon","value":""},{"property":"unit_of_measurement","value":"Hz"}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":1140,"y":620,"wires":[[]]},{"id":"33b002fe.33b9ae","type":"template","z":"51ab8a82.65a544","name":"AC Frequency Value","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{{payload.root.Device.0.Measurements.0.Measurement.3.$.Value}}","output":"str","x":880,"y":620,"wires":[["8a2d5941.1baac8"]]},{"id":"aba82e4.137cfd","type":"ha-entity","z":"51ab8a82.65a544","name":"Temperature Sensor","server":"1d3ab900.3ac2d7","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"kostal_piko_temperature"},{"property":"device_class","value":"temperature"},{"property":"icon","value":""},{"property":"unit_of_measurement","value":"°C"}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":1140,"y":800,"wires":[[]]},{"id":"4381d510.5c271c","type":"template","z":"51ab8a82.65a544","name":"Temperature Value","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{{payload.root.Device.0.Measurements.0.Measurement.6.$.Value}}","output":"str","x":870,"y":800,"wires":[["aba82e4.137cfd"]]},{"id":"6a546d1d.c8c384","type":"ha-entity","z":"51ab8a82.65a544","name":"Grid Power Sensor","server":"1d3ab900.3ac2d7","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"kostal_piko_grid_power"},{"property":"device_class","value":"power"},{"property":"icon","value":""},{"property":"unit_of_measurement","value":"W"}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":1130,"y":860,"wires":[[]]},{"id":"9df0ab72.82c958","type":"template","z":"51ab8a82.65a544","name":"Grid Power Value","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{{payload.root.Device.0.Measurements.0.Measurement.7.$.Value}}","output":"str","x":870,"y":860,"wires":[["6a546d1d.c8c384"]]},{"id":"c1c284ab.ca46a8","type":"ha-entity","z":"51ab8a82.65a544","name":"Derating Sensor","server":"1d3ab900.3ac2d7","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"kostal_piko_derating"},{"property":"device_class","value":"power_factor"},{"property":"icon","value":""},{"property":"unit_of_measurement","value":"%"}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":1120,"y":920,"wires":[[]]},{"id":"acdefcf2.2745d","type":"template","z":"51ab8a82.65a544","name":"Derating Value","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{{payload.root.Device.0.Measurements.0.Measurement.8.$.Value}}","output":"str","x":860,"y":920,"wires":[["c1c284ab.ca46a8"]]},{"id":"1d3ab900.3ac2d7","type":"server","name":"Home Assistant","addon":true}]

And this is what it looks like on your dashboard:

2 Likes

Hi,
this looks great, and would allow me and for sure others to ditch a custome add-on which is not develeoped any more.
So having a more native automation without node-red would be such a GREAT thing and would love to test it and play around. Less dependencies make less troubles :smiley:

Thanks

1 Like

any update on this?
could this be used without red-node - someone already successfully implemented this ?