#Node-Red Lighting Error.

1 messages · Page 1 of 1 (latest)

neon junco
#

Afternoon All,
I'm having some issue with trying to get the formatting of this right,

https://hastebin.com/share/okikubeyak.lua

I keep getting errors like this.

InputError: Invalid JSON: [object Object]

or other similar errors. I dont want to add brightness and kelvin into the data field of the call service node, and as if i don't want the lights chaning (for what ever reason) the kelvin data might not be there.

neon junco
#

This function:

if (msg.circadian === "on") {
    msg.payload = {
        "brightness_pct": msg.brightness,
        "kelvin": msg.kelvin
    };
} else {
    msg.payload = {
        "brightness_pct": msg.brightness
    };
}

return msg;

with this data field:
"{{ payload }}"

produces this error:
HomeAssistantError: extra keys not allowed @ data['0']

#

chaging the data field on the call service to
{{ payload }}
produces
InputError: Invalid JSON: [object Object]

#

setting the data field to {{{ payload }}}
produces the same error.

#

A debug node shows that the template is outputting the payload as:

#

{"brightness_pct":50,"kelvin":3029}
so it should be correct no?