MQTT Attributes and Cards

@petsie

btw, that flow you created, is that just grabbing some html info? like some sort of screenshot? or how does that work?

@ pergola.fabio

I use Node-Red UI:

Open your node-red instance and you should have UI nodes available at the bottom. The UI interface is available at http://localhost:1880/ui (if default node-red settings are used):

yes but i mean, this flow/code : [{“id”:“6421893c.968b4”,“type”:“tab”,“label”:“Kostal Piko”," …

how did you create that ? is that actually html grabbing what you do here? or how do you get the info from kostal ? is that actually opening some kind of webinterface in background, and then taking html output?

Change the PASSWORD and IPADDRESS

44

This element will get the request from the Kostal device as HTML and create the
GUI elements and the MQTT data for the HAS.
The flows can be used as an alternative to the node.js mqtt scripts.

"url": "http://pvserver:PASSWORD@IPADDRESS",
[
   {
      "id": "6421893c.968b4",
      "type": "tab",
      "label": "Kostal Piko",
      "disabled": false,
      "info": "All data from the kostal piko device and all\ns0 sensors..."
   },
   {
      "id": "5a855f4f.2a0728",
      "type": "inject",
      "z": "6421893c.968b4",
      "name": "Timer for data",
      "topic": "",
      "payload": "",
      "payloadType": "date",
      "repeat": "60",
      "crontab": "",
      "once": true,
      "onceDelay": "",
      "x": 120,
      "y": 180,
      "wires": [
         [
            "ab2edc17.89f03",
            "132be680.13c062",
            "78980e1e.2ee6b8"
         ]
      ]
   },
   {
      "id": "efd3d962.139b08",
      "type": "html",
      "z": "6421893c.968b4",
      "name": "Watt aktuell",
      "tag": "body > form > font > table:nth-child(2) > tr:nth-child(4) > td:nth-child(3)",
      "ret": "text",
      "as": "multi",
      "x": 550,
      "y": 640,
      "wires": [
         [
            "559eb16b.9b761"
         ]
      ],
      "outputLabels": [
         "watt"
      ]
   },
   {
      "id": "ab2edc17.89f03",
      "type": "http request",
      "z": "6421893c.968b4",
      "name": "Request: SET PASSWORD && IPADDRESS",
      "method": "GET",
      "ret": "txt",
      "url": "http://pvserver:PASSWORD@IPADDRESS",
      "tls": "",
      "x": 270,
      "y": 480,
      "wires": [
         [
            "efd3d962.139b08",
            "ca195eeb.84edf8",
            "7a9012cc.1145dc"
         ]
      ]
   },
   {
      "id": "ca195eeb.84edf8",
      "type": "html",
      "z": "6421893c.968b4",
      "name": "Tag kWh",
      "tag": "body > form > font > table:nth-child(2) > tr:nth-child(6) > td:nth-child(6)",
      "ret": "text",
      "as": "multi",
      "x": 540,
      "y": 360,
      "wires": [
         [
            "559eb16b.9b761"
         ]
      ],
      "outputLabels": [
         "daykwh"
      ]
   },
   {
      "id": "7a9012cc.1145dc",
      "type": "html",
      "z": "6421893c.968b4",
      "name": "Gesamtenergie kWh",
      "tag": "body > form > font > table:nth-child(2) > tr:nth-child(4) > td:nth-child(6)",
      "ret": "text",
      "as": "multi",
      "x": 580,
      "y": 740,
      "wires": [
         [
            "559eb16b.9b761"
         ]
      ],
      "outputLabels": [
         "kwh"
      ]
   },
   {
      "id": "559eb16b.9b761",
      "type": "join",
      "z": "6421893c.968b4",
      "name": "",
      "mode": "custom",
      "build": "array",
      "property": "payload",
      "propertyType": "msg",
      "key": "topic",
      "joiner": "\\n",
      "joinerType": "str",
      "accumulate": false,
      "timeout": "1",
      "count": "3",
      "x": 630,
      "y": 500,
      "wires": [
         [
            "938d9079.2d79d8",
            "24fdee5.816a012",
            "6b2b7b1e.c37b64",
            "ef8307b2.91ce1",
            "40c9d85a.9f19f8"
         ]
      ]
   },
   {
      "id": "40c9d85a.9f19f8",
      "type": "debug",
      "z": "6421893c.968b4",
      "name": "",
      "active": false,
      "console": "false",
      "complete": "payload.watt",
      "x": 830,
      "y": 320,
      "wires": []
   },
   {
      "id": "938d9079.2d79d8",
      "type": "function",
      "z": "6421893c.968b4",
      "name": "build payload",
      "func": "var payload = msg.payload,\n    o = {};\n    o.device   = \"Kostal PIKO 5.5 \";\n    o.time     = new Date().toLocaleString();\n    o.watt     = 0.00;\n    o.daykwh   = 0.00;\n    o.totalkwh = 0.00;\n// build the payload for the mqtt broker\nif(payload && payload.length) {\n   o.watt      = parseFloat(payload[0].replace(/\\r?\\n?/g, '').trim())||0.00;\n   o.daykwh    = parseFloat(payload[1].replace(/\\r?\\n?/g, '').trim())||0.00;\n   o.totalkwh  = parseFloat(payload[2].replace(/\\r?\\n?/g, '').trim())||0.00;\n   return {payload: o};\n} else {\n    return {payload: o};\n}",
      "outputs": 1,
      "noerr": 0,
      "x": 808.5,
      "y": 449,
      "wires": [
         [
            "c670457c.c1fdb8"
         ]
      ]
   },
   {
      "id": "c670457c.c1fdb8",
      "type": "mqtt out",
      "z": "6421893c.968b4",
      "name": "",
      "topic": "tele/kostal/pikodata",
      "qos": "0",
      "retain": "true",
      "broker": "359f0f5a.21b0c8",
      "x": 1085,
      "y": 447,
      "wires": []
   },
   {
      "id": "24fdee5.816a012",
      "type": "function",
      "z": "6421893c.968b4",
      "name": "Watt",
      "func": "var payload = msg.payload;\nvar watt = parseFloat(payload[0].replace(/\\r?\\n?/g, '').trim())||0.00;\nreturn {payload: watt};",
      "outputs": 1,
      "noerr": 0,
      "x": 790,
      "y": 517,
      "wires": [
         [
            "3db83bd8.cf0444"
         ]
      ]
   },
   {
      "id": "739861e7.0d058",
      "type": "ui_gauge",
      "z": "6421893c.968b4",
      "name": "",
      "group": "2c0d5acd.50dd7e",
      "order": 0,
      "width": 0,
      "height": 0,
      "gtype": "gage",
      "title": "Tagesleistung kWh",
      "label": "W",
      "format": "{{value}}",
      "min": 0,
      "max": "12.00",
      "colors": [
         "#00b500",
         "#e6e600",
         "#ca3838"
      ],
      "seg1": "",
      "seg2": "",
      "x": 990,
      "y": 565,
      "wires": []
   },
   {
      "id": "6b2b7b1e.c37b64",
      "type": "function",
      "z": "6421893c.968b4",
      "name": "Day kWh",
      "func": "var payload = msg.payload;\nvar watt = parseFloat(payload[1].replace(/\\r?\\n?/g, '').trim())||0.00;\nreturn {payload: watt};",
      "outputs": 1,
      "noerr": 0,
      "x": 800.5,
      "y": 565,
      "wires": [
         [
            "739861e7.0d058"
         ]
      ]
   },
   {
      "id": "ef8307b2.91ce1",
      "type": "function",
      "z": "6421893c.968b4",
      "name": "Total kWh",
      "func": "var payload = msg.payload;\nvar watt = parseFloat(payload[2].replace(/\\r?\\n?/g, '').trim())||0.00;\nreturn {payload: watt};",
      "outputs": 1,
      "noerr": 0,
      "x": 801.5,
      "y": 614,
      "wires": [
         [
            "33f0029e.b58166"
         ]
      ]
   },
   {
      "id": "3db83bd8.cf0444",
      "type": "ui_chart",
      "z": "6421893c.968b4",
      "name": "",
      "group": "2c0d5acd.50dd7e",
      "order": 0,
      "width": 0,
      "height": 0,
      "label": "Aktuell Watt",
      "chartType": "line",
      "legend": "false",
      "xformat": "HH:mm",
      "interpolate": "linear",
      "nodata": "",
      "dot": false,
      "ymin": "",
      "ymax": "",
      "removeOlder": 1,
      "removeOlderPoints": "",
      "removeOlderUnit": "3600",
      "cutout": 0,
      "useOneColor": false,
      "colors": [
         "#1f77b4",
         "#aec7e8",
         "#ff7f0e",
         "#2ca02c",
         "#98df8a",
         "#d62728",
         "#ff9896",
         "#9467bd",
         "#c5b0d5"
      ],
      "useOldStyle": false,
      "x": 969.5,
      "y": 517,
      "wires": [
         [],
         []
      ]
   },
   {
      "id": "33f0029e.b58166",
      "type": "ui_chart",
      "z": "6421893c.968b4",
      "name": "",
      "group": "2c0d5acd.50dd7e",
      "order": 0,
      "width": 0,
      "height": 0,
      "label": "Gesamtleistung",
      "chartType": "line",
      "legend": "false",
      "xformat": "HH:mm",
      "interpolate": "linear",
      "nodata": "",
      "dot": false,
      "ymin": "",
      "ymax": "",
      "removeOlder": 1,
      "removeOlderPoints": "",
      "removeOlderUnit": "3600",
      "cutout": 0,
      "useOneColor": false,
      "colors": [
         "#1f77b4",
         "#aec7e8",
         "#ff7f0e",
         "#2ca02c",
         "#98df8a",
         "#d62728",
         "#ff9896",
         "#9467bd",
         "#c5b0d5"
      ],
      "useOldStyle": false,
      "x": 981.5,
      "y": 614,
      "wires": [
         [],
         []
      ]
   },
   {
      "id": "132be680.13c062",
      "type": "debug",
      "z": "6421893c.968b4",
      "name": "",
      "active": false,
      "console": "false",
      "complete": "false",
      "x": 370,
      "y": 240,
      "wires": []
   },
   {
      "id": "b474c455.1cd0c",
      "type": "debug",
      "z": "6421893c.968b4",
      "name": "",
      "active": false,
      "console": "false",
      "complete": "false",
      "x": 590,
      "y": 240,
      "wires": []
   },
   {
      "id": "c1c2d803.d36378",
      "type": "ui_text",
      "z": "6421893c.968b4",
      "group": "2c0d5acd.50dd7e",
      "order": 0,
      "width": 0,
      "height": 0,
      "name": "Current Date",
      "label": "",
      "format": "{{msg.payload}}",
      "layout": "row-right",
      "x": 610,
      "y": 160,
      "wires": []
   },
   {
      "id": "78980e1e.2ee6b8",
      "type": "moment",
      "z": "6421893c.968b4",
      "name": "",
      "topic": "",
      "input": "payload",
      "inputType": "msg",
      "inTz": "Europe/Vatican",
      "adjAmount": "0",
      "adjType": "hours",
      "adjDir": "add",
      "format": "dd, MM-DD-YYYY h:mm:ss a",
      "locale": "en_GB",
      "output": "payload",
      "outputType": "msg",
      "outTz": "Europe/Vatican",
      "x": 400,
      "y": 180,
      "wires": [
         [
            "b474c455.1cd0c",
            "c1c2d803.d36378"
         ]
      ]
   },
   {
      "id": "359f0f5a.21b0c8",
      "type": "mqtt-broker",
      "z": "",
      "broker": "10.1.1.94",
      "port": "1883",
      "clientid": "ndredMqtt",
      "usetls": false,
      "compatmode": true,
      "keepalive": "60",
      "cleansession": true,
      "birthTopic": "",
      "birthQos": "0",
      "birthPayload": "",
      "willTopic": "",
      "willQos": "0",
      "willPayload": ""
   },
   {
      "id": "2c0d5acd.50dd7e",
      "type": "ui_group",
      "z": "",
      "name": "Kostal Piko 5.5 Anlage",
      "tab": "aa717a22.25e1b",
      "order": 3,
      "disp": true,
      "width": "6"
   },
   {
      "id": "aa717a22.25e1b",
      "type": "ui_tab",
      "z": "",
      "name": "3. OG",
      "icon": "dashboard",
      "order": 5
   }
]

cool, thnx a lor for sharing, gonna try it later

you figured out that code yourself?
nice!!

Hello all,
I made a fork of https://github.com/Tafkas/KostalPikoPy to support python3 for pikopy.
And I also made a custom component for Kostal Piko in Home-Assistant, https://github.com/gieljnssns/My-Hassio-config/blob/master/config/custom_components/sensor/kostal.py .
The yams config is like this:

  - platform: kostal
    host: 'http://192.168.xx.xx'
    username: xxxxxxxxxx
    password: xxxxxxxxxx
    monitored_conditions:
      - solar_generator_power
      - consumption_phase_1
      - consumption_phase_2
      - consumption_phase_3
      - current_power
      - total_energy
      - daily_energy
      - string1_voltage
      - string1_current
      - string2_voltage
      - string2_current
      - string3_voltage
      - string3_current
      - l1_voltage
      - l1_power
      - l2_voltage
      - l2_power
      - l3_voltage
      - l3_power

solar_generator_power, consumption_phase_1, consumption_phase_2, consumption_phase_3 are only supported when you have a Kostal BA sensor installed (this is untested, I don’t have a BA sensor, code comes from https://github.com/lucasHSA/KostalPikoPy)

When this is all working I can make a PR to the original repository (so it can be installed with pip) and maybe a PR to HA…

Feedback welcome

I was about to test it out next week, the nodered option, I don’t have a BA sensor :frowning:

@pergola.fabio
only

      - solar_generator_power
      - consumption_phase_1
      - consumption_phase_2
      - consumption_phase_3

need a BA sensor

Ah ok, cool, indeed , I was reading your reply to fast :wink:

ok, tried your py file, lots of sensors :slight_smile:
after what time is the data refreshed?

Every 30 seconds.

can you define that somewhere? or is it just the default scan_interval ?

It’s the default.
But you can try to overrule https://www.home-assistant.io/docs/configuration/platform_options/#scan-interval

Ok, tried your add-on, it’s working very good…
Is it also possible to display historical data like on solar online portal, like block graphs per month

I think you need to download historical data from it

@gieljnssns can you make that an official component, kostal piko is working fine…?

Hi gieljnssns

Your github destination https://github.com/gieljnssns/My-Hassio-config/blob/master/config/custom_components/sensor/kostal.py is no longer available. Is it possible that you would like to share the component again?

hey

i am using it also

here you go, a copy of mine

1 Like

Hey,
can you share your file with me pls.
sensor.py for kostal

You can find it here

And here