IF node is not returning correct output (anymore)

Had this really simple script working for a while and all of a sudden it only triggers the false branch … regardless of the input (could also be true or false).

grafik

Hey @daniello,

Thanks for creating a separate topic!

Is the data type of the value you pass in the Value 1 field boolean or string?

I believe its boolean because it sais so in the prefs. True and False do appear properly.

grafik

Hey @daniello,

I checked the workflow that you shared here: 0.134.0 Mqtt Trigger broken - #6 by daniello

I tested it and I got the following result

If you observe, the value in the message that I get is a string. To get the boolean, you should enable the JSON Parse Body additional option. This will return the values with the right data type. You can then refer to the value in the IF node.
Here’s the output with the JSON Parse Body option.

Here’s the updated workflow

{
  "nodes": [
    {
      "parameters": {
        "topics": "harshil1712-n8n",
        "options": {
          "jsonParseBody": true,
          "onlyMessage": false
        }
      },
      "name": "MQTT Trigger",
      "type": "n8n-nodes-base.mqttTrigger",
      "typeVersion": 1,
      "position": [
        400,
        300
      ],
      "credentials": {
        "mqtt": "[email protected]"
      }
    },
    {
      "parameters": {
        "conditions": {
          "boolean": [
            {
              "value1": "={{$json[\"message\"][\"check\"]}}",
              "value2": true
            }
          ]
        }
      },
      "name": "IF",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        600,
        300
      ]
    }
  ],
  "connections": {
    "MQTT Trigger": {
      "main": [
        [
          {
            "node": "IF",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

Ah … forgot to press save the first try … thought this was auto-save. Seems to work now with that option … let me do some more tests.

1 Like

daniello

1m

  1. Deactivate the workflow and delete all pushover messages
  2. I activate the workflow → 2 true pushover messages (true is correct, 2 is incorrect)
  3. I send false → 1 false message
  4. I send true → 1 true message

Nr. 2 is a separate ticket … plus it bounces (why 2 messages).

Thanks so far!
(I wonder why my script formerly worked)