Node-Red, MQTT output is giving {"Command":"Unknown"} error. Please help

I’m using Node-Red in Hass.io to deliver an MQTT output to turn on a switch, but I am pulling my hair out trying to get this to work. My flow looks like this.

My MQTT output switch is configured as follows:

Server: 192.168.1.20
Topic: cmnd/switch_mjswitch2
QoS : blank
Retain: true
Name: blank

I am using an inject node to test it, by injecting a msg.payload of “On”, “on”, or “ON”, or “Power 1” but no matter what I do, I cannot get the command to pass onto the MQTT client. The node shows as “Connected” (so I am assuming that means it is connected successfully to the broker).

When I look on the client console, I am seeing

18:30:28 MQT: stat/switch_mjswitch2/RESULT = {“Command”:“Unknown”}

Everytime I inject a message, but the device doesn’t respond. I can turn on and off the light from the MQTT console, and I can also do so by calling the service “switch.switch_mjswitch2” directly from home assistant.

Does anyone have a clue where I might be going wrong?

Anyone? Would appreciate if anyone can help

1 Like