Page 2 of 2

Re: Shell recharge API interface

Posted: Friday 11 October 2024 10:58
by Henry
Hi Firewizzard,

Yesterday I went through the documentation to learn about the interaction between Node-Red and Domoticz. I have installed Mosquito on my Pi and added the MQTT hardware in Domoticz.
I created 3 devices in Domoticz that are connected to Node-Red: a Push On Button with what I can poll the status, a switch that can start/stop the charging and a Text device to catch the debug output from Node-Red.
The standard output from Node-Red is also used to toggle the charge switch in case charging is started/stopped in another way.
I also created a small DzVents script that gets fired every hour and toggles the charge switch if the current electricity price is above or below a certain threshold.
I'm not able to send you the Node-Red flow and the output today but will do that a.s.a.p.
Thanks for your effort.

Regards, Henry

Re: Shell recharge API interface

Posted: Friday 11 October 2024 15:25
by FireWizard
Hello @Henry,

You wrote:
I created 3 devices in Domoticz that are connected to Node-Red: a Push On Button with what I can poll the status, a switch that can start/stop the charging and a Text device
I did the same and I created a flow, only with default Node-RED nodes, which is attached below.
I omitted the Shell Recharge Subflow, as this contains a lot of nodes. replace the three "Inject"nodes, for Start, Stop and Poll with this flow.

Sorry, I cannot send a picture or any other attachment as I receive
Error

Sorry, the board attachment quota has been reached.
The standard output from Node-Red is also used to toggle the charge switch in case charging is started/stopped in another way.
This will be created later.
Text device to catch the debug output from Node-Red.
I would not recommend that. Node-RED developers advise to remove the "debug" or at least to disable them, as soon your flow is running fine.
I suggest to connect the status information to that "Text" node.

Below the flow:

1. In the '"Split IDX" node, replace the IDX numbers for your IDX numbers. The first one for the "Poll" button, the second one for the "Start/Stop" switch.
2. Insert your own MQTT configuration.

Code: Select all

[
    {
        "id": "2074b068e61ad6e2",
        "type": "mqtt in",
        "z": "0395707f6d3c0639",
        "name": "From Domoticz",
        "topic": "domoticz/out",
        "qos": "2",
        "datatype": "auto-detect",
        "broker": "914e5d6751284bd7",
        "nl": false,
        "rap": true,
        "rh": 0,
        "inputs": 0,
        "x": 140,
        "y": 620,
        "wires": [
            [
                "989856c5187ad61d"
            ]
        ]
    },
    {
        "id": "989856c5187ad61d",
        "type": "switch",
        "z": "0395707f6d3c0639",
        "name": "Spli IDX",
        "property": "payload.idx",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "7",
                "vt": "num"
            },
            {
                "t": "eq",
                "v": "8",
                "vt": "num"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 340,
        "y": 620,
        "wires": [
            [
                "799b28b3257bc554"
            ],
            [
                "b6a7c4d4e75820b8"
            ]
        ]
    },
    {
        "id": "799b28b3257bc554",
        "type": "change",
        "z": "0395707f6d3c0639",
        "name": "Set Poll",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "  { \"action\": \"poll\" }",
                "tot": "json"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 720,
        "y": 600,
        "wires": [
            [
                "0d363e613357400d"
            ]
        ]
    },
    {
        "id": "b6a7c4d4e75820b8",
        "type": "switch",
        "z": "0395707f6d3c0639",
        "name": "Split On/Off",
        "property": "payload.nvalue",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "0",
                "vt": "num"
            },
            {
                "t": "eq",
                "v": "1",
                "vt": "num"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 530,
        "y": 660,
        "wires": [
            [
                "4aae1ea82fd7019c"
            ],
            [
                "2f4d6af897f818f1"
            ]
        ]
    },
    {
        "id": "4aae1ea82fd7019c",
        "type": "change",
        "z": "0395707f6d3c0639",
        "name": "Set Stop",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "  { \"action\": \"stop\" }",
                "tot": "json"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 720,
        "y": 640,
        "wires": [
            [
                "0d363e613357400d"
            ]
        ]
    },
    {
        "id": "2f4d6af897f818f1",
        "type": "change",
        "z": "0395707f6d3c0639",
        "name": "Set Start",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "  { \"action\": \"start\" }",
                "tot": "json"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 720,
        "y": 680,
        "wires": [
            [
                "0d363e613357400d"
            ]
        ]
    },
    {
        "id": "019bb90a657ed1cc",
        "type": "inject",
        "z": "0395707f6d3c0639",
        "name": "Setup",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "{ \"action\": \"setup\" }",
        "payloadType": "json",
        "x": 730,
        "y": 720,
        "wires": [
            [
                "0d363e613357400d"
            ]
        ]
    },
    {
        "id": "914e5d6751284bd7",
        "type": "mqtt-broker",
        "name": "",
        "broker": "192.168.10.51",
        "port": "1883",
        "clientid": "",
        "autoConnect": true,
        "usetls": false,
        "protocolVersion": "4",
        "keepalive": "60",
        "cleansession": true,
        "autoUnsubscribe": true,
        "birthTopic": "",
        "birthQos": "0",
        "birthRetain": "false",
        "birthPayload": "",
        "birthMsg": {},
        "closeTopic": "",
        "closeQos": "0",
        "closeRetain": "false",
        "closePayload": "",
        "closeMsg": {},
        "willTopic": "",
        "willQos": "0",
        "willRetain": "false",
        "willPayload": "",
        "willMsg": {},
        "userProps": "",
        "sessionExpiry": ""
    }
]
Let me know,

Regards

Re: Shell recharge API interface

Posted: Saturday 12 October 2024 13:40
by Henry
I did the same and I created a flow, only with default Node-RED nodes, which is attached below.
Thanks for the flow, it's a great way to learn about Node-Red. I changed it a bit to prevent the Poll to be executed when it's turned off.
Node-RED developers advise to remove the "debug" or at least to disable them, as soon your flow is running fine.
I suggest to connect the status information to that "Text" node.
I understand but the Poll doesn't give anything on the standard output, and for now it's a nice way to see what's happening. If everything is running fine I will disable the debug output.

This is the input flow

Code: Select all

[
    {
        "id": "ce4eda975b3ddb38",
        "type": "tab",
        "label": "Flow 2",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "c96c382a258260dc",
        "type": "mqtt in",
        "z": "ce4eda975b3ddb38",
        "name": "From Domoticz",
        "topic": "domoticz/out",
        "qos": "2",
        "datatype": "auto-detect",
        "broker": "86f0c28c.790f4",
        "nl": false,
        "rap": true,
        "rh": 0,
        "inputs": 0,
        "x": 200,
        "y": 260,
        "wires": [
            [
                "3bf37797e167b703"
            ]
        ]
    },
    {
        "id": "3bf37797e167b703",
        "type": "switch",
        "z": "ce4eda975b3ddb38",
        "name": "Split IDX",
        "property": "payload.idx",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "307",
                "vt": "num"
            },
            {
                "t": "eq",
                "v": "308",
                "vt": "num"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 380,
        "y": 260,
        "wires": [
            [
                "e9fc7cf3fbb69a0c"
            ],
            [
                "1b3d8309d457b381"
            ]
        ]
    },
    {
        "id": "21453f97270108fa",
        "type": "change",
        "z": "ce4eda975b3ddb38",
        "name": "Set Poll",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "  { \"action\": \"poll\" }",
                "tot": "json"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 780,
        "y": 240,
        "wires": [
            []
        ]
    },
    {
        "id": "1b3d8309d457b381",
        "type": "switch",
        "z": "ce4eda975b3ddb38",
        "name": "Split On/Off",
        "property": "payload.nvalue",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "0",
                "vt": "num"
            },
            {
                "t": "eq",
                "v": "1",
                "vt": "num"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 570,
        "y": 300,
        "wires": [
            [
                "9407d73946af319b"
            ],
            [
                "56fd9b28c1869043"
            ]
        ]
    },
    {
        "id": "9407d73946af319b",
        "type": "change",
        "z": "ce4eda975b3ddb38",
        "name": "Set Stop",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "  { \"action\": \"stop\" }",
                "tot": "json"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 780,
        "y": 280,
        "wires": [
            []
        ]
    },
    {
        "id": "56fd9b28c1869043",
        "type": "change",
        "z": "ce4eda975b3ddb38",
        "name": "Set Start",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "  { \"action\": \"start\" }",
                "tot": "json"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 780,
        "y": 320,
        "wires": [
            []
        ]
    },
    {
        "id": "2b6b6ab4e7178487",
        "type": "inject",
        "z": "ce4eda975b3ddb38",
        "name": "Setup",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "{ \"action\": \"setup\" }",
        "payloadType": "json",
        "x": 790,
        "y": 360,
        "wires": [
            []
        ]
    },
    {
        "id": "e9fc7cf3fbb69a0c",
        "type": "switch",
        "z": "ce4eda975b3ddb38",
        "name": "Split On/Off",
        "property": "payload.nvalue",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "1",
                "vt": "num"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 1,
        "x": 570,
        "y": 240,
        "wires": [
            [
                "21453f97270108fa"
            ]
        ]
    },
    {
        "id": "86f0c28c.790f4",
        "type": "mqtt-broker",
        "name": "Domoticz",
        "broker": "localhost",
        "port": "1883",
        "clientid": "",
        "autoConnect": true,
        "usetls": false,
        "protocolVersion": "4",
        "keepalive": "15",
        "cleansession": true,
        "autoUnsubscribe": true,
        "birthTopic": "",
        "birthQos": "0",
        "birthPayload": "",
        "birthMsg": {},
        "closeTopic": "",
        "closePayload": "",
        "closeMsg": {},
        "willTopic": "",
        "willQos": "0",
        "willPayload": "",
        "willMsg": {},
        "userProps": "",
        "sessionExpiry": ""
    }
]
And the output

Code: Select all

[
    {
        "id": "16e2583208241e69",
        "type": "tab",
        "label": "Flow 3",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "1ad4e12651b84e4e",
        "type": "mqtt out",
        "z": "16e2583208241e69",
        "name": "To Domoticz",
        "topic": "domoticz/in",
        "qos": "2",
        "retain": "false",
        "respTopic": "",
        "contentType": "",
        "userProps": "",
        "correl": "",
        "expiry": "",
        "broker": "86f0c28c.790f4",
        "x": 650,
        "y": 380,
        "wires": []
    },
    {
        "id": "0ffc55e25886addc",
        "type": "switch",
        "z": "16e2583208241e69",
        "name": "Split Laden",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "true"
            },
            {
                "t": "false"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 250,
        "y": 360,
        "wires": [
            [
                "e44416ef7e979380"
            ],
            [
                "7a9ef1d5d9dbc742"
            ]
        ]
    },
    {
        "id": "e44416ef7e979380",
        "type": "change",
        "z": "16e2583208241e69",
        "name": "Set Laden aan",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "{\"idx\":308,\"nvalue\": 1}",
                "tot": "json"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 440,
        "y": 340,
        "wires": [
            [
                "1ad4e12651b84e4e"
            ]
        ]
    },
    {
        "id": "7a9ef1d5d9dbc742",
        "type": "change",
        "z": "16e2583208241e69",
        "name": "Set Laden uit",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "{\"idx\":308,\"nvalue\": 0}",
                "tot": "json"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 430,
        "y": 380,
        "wires": [
            [
                "1ad4e12651b84e4e"
            ]
        ]
    },
    {
        "id": "8edc862f95ab7351",
        "type": "change",
        "z": "16e2583208241e69",
        "name": "Set Status",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "{\"idx\":309,\"svalue\":payload}",
                "tot": "jsonata"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 430,
        "y": 420,
        "wires": [
            [
                "1ad4e12651b84e4e"
            ]
        ]
    },
    {
        "id": "86f0c28c.790f4",
        "type": "mqtt-broker",
        "name": "Domoticz",
        "broker": "localhost",
        "port": "1883",
        "clientid": "",
        "autoConnect": true,
        "usetls": false,
        "protocolVersion": "4",
        "keepalive": "15",
        "cleansession": true,
        "autoUnsubscribe": true,
        "birthTopic": "",
        "birthQos": "0",
        "birthPayload": "",
        "birthMsg": {},
        "closeTopic": "",
        "closePayload": "",
        "closeMsg": {},
        "willTopic": "",
        "willQos": "0",
        "willPayload": "",
        "willMsg": {},
        "userProps": "",
        "sessionExpiry": ""
    }
]
And the DzVents script

Code: Select all

return {
    active = true,
    logging = {
	    -- level = domoticz.LOG_DEBUG, -- uncomment for development, else comment and use generic domoticz settings
	    marker = 'Laden'
    },
    on = {
        timer = { 'at *:01' }
    },

    execute = function(dz, item)
	    local laden = dz.devices('Laden')
	    local poll  = dz.devices('Poll')
	    local price = dz.devices('Actual Electricity Price')
	    
	    local MaxElPrice = dz.variables('MaxElPrice').value
	    dz.notify ('Max electricity price: ' .. MaxElPrice)

	    local CurElPrice = price.sensorValue
	    dz.notify ('Current dynamic price: ' .. CurElPrice)
        
        -- poll.switchOn()
        
	    if (item.isTimer) then
            if (CurElPrice < MaxElPrice) then
	            laden.switchOn().checkFirst()
            else
                laden.switchOff().checkFirst()
            end
	    end
    end
}
I noticed that the Poll only gave the charger status (Occupied, Available, Charging), and not if the car is connected.

Re: Shell recharge API interface

Posted: Saturday 12 October 2024 14:08
by FireWizard
Hello @Henry,

You wrote:
I changed it a bit to prevent the Poll to be executed when it's turned off.
That make sense, but I didn´t know exactly wat the result is of pushing the "Poll" button.
I understand but the Poll doesn't give anything on the standard output, and for now it's a nice way to see what's happening.
I do not understand this, as your last line shows:
I noticed that the Poll only gave the charger status (Occupied, Available, Charging), and not if the car is connected.
You can put that in the "Text" widget.

I will import the flows and I will come back to you.

Regards

Re: Shell recharge API interface

Posted: Saturday 12 October 2024 14:17
by Henry
Hi @FireWizzard,

Reading it back I can see it's not that clear, but from the Readme:

Outputs
The Output payload is (boolean) true if a charge is in progress, otherwise it is (boolean) false. This is also updated when polling is in progress. All other output is from Debug labelled with topics like status, poll, response, energy and error.

So this is more than debug info. For example energy:

Code: Select all

{"chartTotal":{"totalkWh":"137,74","totalkgCO2":"114,669","totalTime":325298,"totalSessions":13},"chart":[{"date":"01-10-2024","sessions":1,"kwh":26.53},{"date":"02-10-2024","sessions":0,"kwh":0},{"date":"03-10-2024","sessions":1,"kwh":21.32},{"date":"04-10-2024","sessions":0,"kwh":0},{"date":"05-10-2024","sessions":1,"kwh":5.86},{"date":"06-10-2024","sessions":3,"kwh":28.48},{"date":"07-10-2024","sessions":1,"kwh":21.42},{"date":"08-10-2024","sessions":1,"kwh":21.32},{"date":"09-10-2024","sessions":0,"kwh":0},{"date":"10-10-2024","sessions":5,"kwh":12.81},{"date":"11-10-2024","sessions":0,"kwh":0},{"date":"12-10-2024","sessions":0,"kwh":0}]}

Re: Shell recharge API interface

Posted: Saturday 12 October 2024 14:34
by FireWizard
Hello @Henry,

I think it is clear(at least for me).

If you hoover with your mouse over the outputs of the subflow, marked "Shell "Recharge", you will see for the upper output "Output" en for the lower one, you will see "Debug". Not a very clear explanation of their functions. But that is for something later.

At the upper one, you will find true or false. Is that correct?
At the lower one, you will find the data.

Can you set the configuration of that Debug node to "complete msg object" You can read the topics as well.

Regards

Re: Shell recharge API interface

Posted: Saturday 12 October 2024 15:41
by Henry
Hi @FireWizzard,
At the upper one, you will find true or false. Is that correct?
At the lower one, you will find the data.
That's correct
Can you set the configuration of that Debug node to "complete msg object"
How do I do that? I can't seem to find it Got it
Poll:

Code: Select all

{"_msgid":"042ff7462973f423","payload":"Available","evse":"07005287","topic":"poll","_event":"node:159f5a5fe4049215-bcdf7ec7fb9f8b1e"}
Energy:

Code: Select all

{"_msgid":"7be97e12f193705a","payload":{"chartTotal":{"totalkWh":"137,74","totalkgCO2":"114,669","totalTime":325298,"totalSessions":13},"chart":[{"date":"01-10-2024","sessions":1,"kwh":26.53},{"date":"02-10-2024","sessions":0,"kwh":0},{"date":"03-10-2024","sessions":1,"kwh":21.32},{"date":"04-10-2024","sessions":0,"kwh":0},{"date":"05-10-2024","sessions":1,"kwh":5.86},{"date":"06-10-2024","sessions":3,"kwh":28.48},{"date":"07-10-2024","sessions":1,"kwh":21.42},{"date":"08-10-2024","sessions":1,"kwh":21.32},{"date":"09-10-2024","sessions":0,"kwh":0},{"date":"10-10-2024","sessions":5,"kwh":12.81},{"date":"11-10-2024","sessions":0,"kwh":0},{"date":"12-10-2024","sessions":0,"kwh":0}]},"topic":"energy","_event":"node:159f5a5fe4049215-033a44c5214cb9f0"}

Re: Shell recharge API interface

Posted: Saturday 12 October 2024 19:42
by FireWizard
Hi @ Henry,

As far as I understand, the second output returns "Available" in case of a topic "poll".
According to one of your previous posts, other values are "Occupied" and "Charging"

Do you know, if there are more

Because I think that is the value, you will need in your "Text" node.

In case the topic is equal to Energy the following data is available:

1. totalkWh
2. totalkgCO2
3. totalTime
4. totalSessions:

And also for each day the number of seesions for that day and the amount of kwh for that day.

What is interesting for you to show in Domoticz?

Perhaps only the amount of kWh during the day,

Let me know, what you want.

I assume the switch Start/Stop works en starts or stops the charging. The poll monitors the status and this can be used in the "Text" sensor.

Regards

Re: Shell recharge API interface

Posted: Saturday 12 October 2024 22:52
by Henry
Hi Firewizzard,

As far as I can see “Available”, “Occupied” and “Charging” are the 3 statusses returned by a poll.
What is interesting for you to show in Domoticz?
Perhaps only the amount of kWh during the day
It would be great to have this as a device in Domoticz, the other values are not that important.
The start/stops works indeed as intended.

Re: Shell recharge API interface

Posted: Sunday 13 October 2024 22:26
by FireWizard
hello @Henry,

I wrote in response of your question:
The standard output from Node-Red is also used to toggle the charge switch in case charging is started/stopped in another way.

This will be created later.
I looked to that issue and created the following (part) of the flow.

Code: Select all

[
    {
        "id": "f4a3d3c687ac0f2d",
        "type": "mqtt out",
        "z": "0395707f6d3c0639",
        "name": "To Domoticz",
        "topic": "domoticz/in",
        "qos": "2",
        "retain": "false",
        "respTopic": "",
        "contentType": "",
        "userProps": "",
        "correl": "",
        "expiry": "",
        "broker": "914e5d6751284bd7",
        "x": 810,
        "y": 1560,
        "wires": []
    },
    {
        "id": "90d726d7dbaac2e2",
        "type": "switch",
        "z": "0395707f6d3c0639",
        "name": "Split Laden",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "true"
            },
            {
                "t": "false"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 390,
        "y": 1560,
        "wires": [
            [
                "b7ebf07e8d49df10"
            ],
            [
                "b77e104eee8c5a3a"
            ]
        ]
    },
    {
        "id": "b7ebf07e8d49df10",
        "type": "change",
        "z": "0395707f6d3c0639",
        "name": "Set Laden aan",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "{  \"command\": \"udevice\",  \"idx\" : 308,  \"nvalue\" : 1,  \"parse\": false }",
                "tot": "json"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 600,
        "y": 1540,
        "wires": [
            [
                "f4a3d3c687ac0f2d"
            ]
        ]
    },
    {
        "id": "b77e104eee8c5a3a",
        "type": "change",
        "z": "0395707f6d3c0639",
        "name": "Set Laden uit",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "{  \"command\": \"udevice\",  \"idx\" : 308,  \"nvalue\" : 0,  \"parse\": false }",
                "tot": "json"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 600,
        "y": 1580,
        "wires": [
            [
                "f4a3d3c687ac0f2d"
            ]
        ]
    },
    {
        "id": "2a24bccf500e2865",
        "type": "inject",
        "z": "0395707f6d3c0639",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "true",
        "payloadType": "bool",
        "x": 190,
        "y": 1540,
        "wires": [
            [
                "90d726d7dbaac2e2"
            ]
        ]
    },
    {
        "id": "d7106405632a80d2",
        "type": "inject",
        "z": "0395707f6d3c0639",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "false",
        "payloadType": "bool",
        "x": 190,
        "y": 1580,
        "wires": [
            [
                "90d726d7dbaac2e2"
            ]
        ]
    },
    {
        "id": "914e5d6751284bd7",
        "type": "mqtt-broker",
        "name": "",
        "broker": "192.168.10.51",
        "port": "1883",
        "clientid": "",
        "autoConnect": true,
        "usetls": false,
        "protocolVersion": "4",
        "keepalive": "60",
        "cleansession": true,
        "autoUnsubscribe": true,
        "birthTopic": "",
        "birthQos": "0",
        "birthRetain": "false",
        "birthPayload": "",
        "birthMsg": {},
        "closeTopic": "",
        "closeQos": "0",
        "closeRetain": "false",
        "closePayload": "",
        "closeMsg": {},
        "willTopic": "",
        "willQos": "0",
        "willRetain": "false",
        "willPayload": "",
        "willMsg": {},
        "userProps": "",
        "sessionExpiry": ""
    }
]
Connect the "Switch" node, called "Split Laden" to the first output of the "Shell Recharge" subflow.
You sent me already this part, but I modified it slightly.
It would be great to have this as a device in Domoticz, the other values are not that important.
I created a small flow in order to send the Status information from the polling to the "Text" sensor and also the used Energy of the last day to a "Counter" in Domoticz, which is configured as Type: Energy. I might be needed to use a "Counter Incremental". Test it.

Code: Select all

[
    {
        "id": "50c7161fdd899f7e",
        "type": "comment",
        "z": "0395707f6d3c0639",
        "name": "Poll Data and Energy Data",
        "info": "",
        "x": 590,
        "y": 1320,
        "wires": []
    },
    {
        "id": "9044d29f49fd6bcb",
        "type": "debug",
        "z": "0395707f6d3c0639",
        "name": "debug 96",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 780,
        "y": 1420,
        "wires": []
    },
    {
        "id": "8e9af352711ce3a7",
        "type": "function",
        "z": "0395707f6d3c0639",
        "name": "Data to Domoticz",
        "func": "if (msg.topic == \"poll\") {\n    var idx = 9;\n    msg.payload = { \"command\": \"udevice\", \"idx\": idx, \"nvalue\": 0, \"svalue\": msg.payload.payload };\n} else if (msg.topic == \"energy\") {\n    var idx = 10;\n    msg.payload = { \"command\": \"udevice\", \"idx\": idx, \"nvalue\": 0, \"svalue\": ((msg.payload.chart[msg.payload.chart.length - 1].kwh) * 1000).toString() };\n}\n\nreturn msg",
        "outputs": 1,
        "timeout": 0,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 570,
        "y": 1360,
        "wires": [
            [
                "9044d29f49fd6bcb",
                "de245197690cf2fa"
            ]
        ]
    },
    {
        "id": "de245197690cf2fa",
        "type": "mqtt out",
        "z": "0395707f6d3c0639",
        "name": "To Domoticz",
        "topic": "domoticz/in",
        "qos": "2",
        "retain": "false",
        "respTopic": "",
        "contentType": "",
        "userProps": "",
        "correl": "",
        "expiry": "",
        "broker": "914e5d6751284bd7",
        "x": 790,
        "y": 1360,
        "wires": []
    },
    {
        "id": "914e5d6751284bd7",
        "type": "mqtt-broker",
        "name": "",
        "broker": "192.168.10.51",
        "port": "1883",
        "clientid": "",
        "autoConnect": true,
        "usetls": false,
        "protocolVersion": "4",
        "keepalive": "60",
        "cleansession": true,
        "autoUnsubscribe": true,
        "birthTopic": "",
        "birthQos": "0",
        "birthRetain": "false",
        "birthPayload": "",
        "birthMsg": {},
        "closeTopic": "",
        "closeQos": "0",
        "closeRetain": "false",
        "closePayload": "",
        "closeMsg": {},
        "willTopic": "",
        "willQos": "0",
        "willRetain": "false",
        "willPayload": "",
        "willMsg": {},
        "userProps": "",
        "sessionExpiry": ""
    }
]
Connect the input of the "Function" node to the second output of the "Shell Recharge" subflow. an test.
Do not forget to reconfigure the MQTT to your values and adjust in the "Function" node at line 2 and 5 the IDX numbers to what you have configured in Domoticz,

Test it and let me know.

Regards

Re: Shell recharge API interface

Posted: Tuesday 15 October 2024 17:00
by Henry
Hi @FireWizzard,

I have added your flows and it's working great. I can see the data in de Energy counter in Domoticz.
I'm going to test some things and see what the outcome is.
Thanks and I will get back soon with my findings.

Re: Shell recharge API interface

Posted: Tuesday 22 October 2024 11:10
by Henry
Hi @FireWizzard,

The flow is running for some time now and it's working good. I've added a timer that retrieves the energy information since midnight every 5 minutes.
Only thing is that there is no good indication if the car is connected or not. I'm going to see if that can be solved as soon as I can get the Kia integration working but for that I have to update my Pi.
Thanks for your input, I got to learn a lot about MQTT and Node-RED.
This is the flow for the energy poll

Code: Select all

[
    {
        "id": "ea625032ef2b7e4e",
        "type": "inject",
        "z": "0395707f6d3c0639",
        "name": "Every 5 mins",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "300",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 460,
        "y": 580,
        "wires": [
            [
                "8d6c86bac34f32e5"
            ]
        ]
    },
    {
        "id": "8d6c86bac34f32e5",
        "type": "function",
        "z": "0395707f6d3c0639",
        "name": "Set Energy",
        "func": "var now = new Date(msg.payload)\nvar midnight = now.setHours(0,0,0,0)\nmsg.payload = {\"action\": \"energy\", \"range\": {\"start\": midnight,\"end\": msg.payload}}\nreturn msg;",
        "outputs": 1,
        "timeout": 0,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 650,
        "y": 580,
        "wires": [
            [
                "159f5a5fe4049215"
            ]
        ]
    }
]

Re: Shell recharge API interface

Posted: Wednesday 23 October 2024 20:22
by FireWizard
Good evening @Henry,

You wrote:
Only thing is that there is no good indication if the car is connected or not.
Isn't that indicated by the "Status" information "Occupied"?
I'm going to see if that can be solved as soon as I can get the Kia integration working but for that I have to update my Pi.
Is that really necessary, to update your Pi? Or do you mean your OS on that Pi.

Also your KIA can be linked to Node-RED.
See: https://flows.nodered.org/node/node-red ... -bluelinky

Regards

Re: Shell recharge API interface

Posted: Thursday 24 October 2024 11:27
by Henry
Hello @FireWizard,

The status is 'Available' even if the car is connected and not charging. If the car is charging then the status changes to 'Charging'. I'm not sure in what situation the status is set to 'Occupied'.
FireWizard wrote: Wednesday 23 October 2024 20:22 Is that really necessary, to update your Pi? Or do you mean your OS on that Pi.
The Kia plugin requires Pyton 3.9 or higher so I have to manually install this or update the OS from Buster to Bullseye and/or Bookworm.
FireWizard wrote: Wednesday 23 October 2024 20:22 Also your KIA can be linked to Node-RED.
See: https://flows.nodered.org/node/node-red ... -bluelinky
That's great! I've got it running and will see were this will get me.
Thanks