Error message to Domoticz

Moderator: leecollings

Post Reply
Henry
Posts: 29
Joined: Tuesday 06 March 2018 18:56
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.7
Location: Netherlands
Contact:

Error message to Domoticz

Post by Henry »

I've created a small Node-Red flow that reads the information from my Kia EV6 using Bluelinky every 10 minutes.
Most of the time this goes ok, but sometimes there is an error in the communication. Now i'm looking for a way to send part of this message to Domoticz.
The error looks like this:

Code: Select all

ManagedBluelinkyError: @EuropeVehicle.fullStatus: [401] Unauthorized on [GET] https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fprd.eu-ccapi.kia.com%3A8080%2Fapi%2Fv2%2Fspa%2Fvehicles%2Fd717d170-e9b2-4000-9144-4cc82bff4ad1/location - {"error":"Key not authorized: Token is expired"}
And I want the part between braces sent to a Domoticz device.
Because it's not a json message I'm note sure how I can handle this.
User avatar
FireWizard
Posts: 1770
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: Error message to Domoticz

Post by FireWizard »

Hello Henry,

You wrote:
Most of the time this goes ok, but sometimes there is an error in the communication.


The error message tells you that the "Key not authorized: Token is expired" .

I would recommend to renew the token, however I do not know what BlueLinky requires.
Sending it to Domoticz doesn't look very useful, unless you want a notification.
I would say, use the message as a trigger to renew the token.
And I want the part between braces sent to a Domoticz device.
I think you mean the part between the curly brackets:

Code: Select all

{"error":"Key not authorized: Token is expired"}
This is JSON and the only thing we have to do is to extract that JSON part from the string.

Currently it is not possible to add a screenshot.

See flow below:

Code: Select all

[
    {
        "id": "bd198a1a36d1f4b5",
        "type": "inject",
        "z": "660311734f481f3a",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "ManagedBluelinkyError: @EuropeVehicle.fullStatus: [401] Unauthorized on [GET] https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fprd.eu-ccapi.kia.com%3A8080%2Fapi%2Fv2%2Fspa%2Fvehicles%2Fd717d170-e9b2-4000-9144-4cc82bff4ad1/location - {\"error\":\"Key not authorized: Token is expired\"}",
        "payloadType": "str",
        "x": 790,
        "y": 140,
        "wires": [
            [
                "b588b09dfa693a99"
            ]
        ]
    },
    {
        "id": "b588b09dfa693a99",
        "type": "string",
        "z": "660311734f481f3a",
        "name": "",
        "methods": [
            {
                "name": "between",
                "params": [
                    {
                        "type": "str",
                        "value": "{"
                    },
                    {
                        "type": "str",
                        "value": "}"
                    }
                ]
            },
            {
                "name": "ensureLeft",
                "params": [
                    {
                        "type": "str",
                        "value": "{"
                    }
                ]
            },
            {
                "name": "append",
                "params": [
                    {
                        "type": "str",
                        "value": "}"
                    }
                ]
            }
        ],
        "prop": "payload",
        "propout": "payload",
        "object": "msg",
        "objectout": "msg",
        "x": 950,
        "y": 140,
        "wires": [
            [
                "8cc844613b9c3c7e"
            ]
        ]
    },
    {
        "id": "38344109b7bc037d",
        "type": "debug",
        "z": "660311734f481f3a",
        "name": "debug 304",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 1290,
        "y": 140,
        "wires": []
    },
    {
        "id": "8cc844613b9c3c7e",
        "type": "json",
        "z": "660311734f481f3a",
        "name": "",
        "property": "payload",
        "action": "",
        "pretty": false,
        "x": 1110,
        "y": 140,
        "wires": [
            [
                "38344109b7bc037d"
            ]
        ]
    }
]
You have to add a contrib node with the Palette Manager (node-red-contrib-string)

Regards
Henry
Posts: 29
Joined: Tuesday 06 March 2018 18:56
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.7
Location: Netherlands
Contact:

Re: Error message to Domoticz

Post by Henry »

Hi Firewizard,
FireWizard wrote: Wednesday 30 October 2024 15:49
The error message tells you that the "Key not authorized: Token is expired" .

I would recommend to renew the token, however I do not know what BlueLinky requires.
Sending it to Domoticz doesn't look very useful, unless you want a notification.
I would say, use the message as a trigger to renew the token.
For now it's just a notification to see how often this happens. There is a limit of 200 calls per day to the api and I don't want to create an endless loop caused by a trigger.
It's working so I will see if it's a problem that is resolved by a next call.

Thanks
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests