Exec node with "timedatectl" call started to return a buffer instead of string

Hi all,

I'm facing a super weird issue. I'm using an exec node with a "timedatectl" call, but suddenly it started to return a buffer instead of string.

Because of that, I can't use any JSONata expression anymore since my payload is a buffer and not a string.

Do you have any idea as to how to change the exec node payload output back to a string instead of a buffer ?

Could you post an example of what your doing with the exec node?

And maybe some info what a "timedatectl" call is

And OS info would be handy as well

Can you post whole of that flow and not just the last node please :slight_smile:

Oooops my bad !

[
    {
        "id": "d6cd57fac03f2437",
        "type": "tab",
        "label": "Flow 1",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "64889f2be479953a",
        "type": "exec",
        "z": "d6cd57fac03f2437",
        "command": "timedatectl status",
        "addpay": "",
        "append": "",
        "useSpawn": "false",
        "timer": "",
        "winHide": false,
        "oldrc": false,
        "name": "",
        "x": 710,
        "y": 280,
        "wires": [
            [
                "dee75bd8f498bd95"
            ],
            [],
            []
        ]
    },
    {
        "id": "547181a76e756d21",
        "type": "inject",
        "z": "d6cd57fac03f2437",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 500,
        "y": 280,
        "wires": [
            [
                "64889f2be479953a"
            ]
        ]
    },
    {
        "id": "dee75bd8f498bd95",
        "type": "switch",
        "z": "d6cd57fac03f2437",
        "name": "",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "cont",
                "v": "Local time:",
                "vt": "str"
            },
            {
                "t": "cont",
                "v": "Universal time:",
                "vt": "str"
            },
            {
                "t": "cont",
                "v": "RTC time:",
                "vt": "str"
            },
            {
                "t": "cont",
                "v": "Time zone:",
                "vt": "str"
            },
            {
                "t": "cont",
                "v": "NTP synchronized:",
                "vt": "str"
            },
            {
                "t": "cont",
                "v": "NTP enabled:",
                "vt": "str"
            },
            {
                "t": "cont",
                "v": "RTC in local TZ:",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 7,
        "x": 930,
        "y": 280,
        "wires": [
            [
                "9c38b86ef7bc180c",
                "4b6de73a7bb007d1"
            ],
            [],
            [],
            [],
            [],
            [],
            []
        ]
    },
    {
        "id": "9c38b86ef7bc180c",
        "type": "change",
        "z": "d6cd57fac03f2437",
        "name": "Create JSON Payload",
        "rules": [
            {
                "t": "set",
                "p": "ntp",
                "pt": "msg",
                "to": "{\t    \"localTime\" : $substringAfter(msg.payload,'Local time: ')\t}",
                "tot": "jsonata"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 1260,
        "y": 240,
        "wires": [
            []
        ]
    },
    {
        "id": "4b6de73a7bb007d1",
        "type": "debug",
        "z": "d6cd57fac03f2437",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 1080,
        "y": 160,
        "wires": []
    }
]

Your flow works for me on RPiOS. The output from the change node seems to be identical to the input though.

Since the exec node (for me) returns a single, multiline, string, the switch node sends the whole payload to each output.

If I undertand what you are trying to achieve, inserting a split node after the exec breaks the string up into individual lines which are then routed correctly by the switch. The change still does nothing.

Unfortunately, that command doesn't work on my Pi so can't test further
image
Sorry for wrong pic 1st time!

But I'd just consider switching NR/computer off and on again to just make sure its just not got upset!

Sorry, I lost you...

Indeed the exec node will return a single, multiline, string.

Do you mean to say that at the end of each line, there is no carriage return \n ?

No. I should have posted the output I get from the exec node:

               Local time: Wed 2021-12-01 09:41:57 GMT
           Universal time: Wed 2021-12-01 09:41:57 UTC
                 RTC time: n/a
                Time zone: Europe/London (GMT, +0000)
System clock synchronized: yes
              NTP service: active
          RTC in local TZ: no

What do you mean by "it started to return a buffer instead of a string"?
You should have posted the output you get from the exec node...

:rofl:

Best thread so far today :slight_smile:

Hahaha I don't know how I should take it... :sweat_smile:

Meant in purely nice way - we've all done such things :slight_smile:

Well I have anyway :slight_smile:

1 Like

Reminds me of the old joke about whether we are running UNIX or Unix or unix....

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.