New to node-red, trouble with an "AND" statement

Good day,

I’ve been having issues with my first Node-Red flow. Part of it already correctly works but I wanted to add an AND statement.

Here is the flow

This takes information from my Gree AC, splits it in topics, then again in run modes.

My cool, dry and heat nodes contain this:

With different swingVert options depending on mode. This works just fine.

What I’d like to do is to add a boolean logic to the “heat” node.

If “Présence Cuisine” is “on”, I would like its payload to be “fixedMid”. If else I want to stay as it is.

Any help is appreciated.

What ever entity this belongs to would go in a current state node. Place that node between run mode and heat. Then add another change node with "fixedMid"

Is there a way for you to show me graphically? Saying I’m a node-red noob is an understatement.

[{"id":"573157b3cd89ee84","type":"api-current-state","z":"60f2d2277843c698","name":"","server":"","version":3,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","entity_id":"Présence Cuisine","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"payload","valueType":"jsonata"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":1050,"y":400,"wires":[[],[]]}]

The output property is important to preserve the original payload. If it is true, the message comes out the top otherwise the bottom.

Okay so I’ve got this so far and I can see it changes state correctly.

Now I need another “Heat” node basically?

Okay, it’s not pretty, but like so?

The event state is not necessary for presence cuisine

We’re getting somewhere. Flipping the boolean on and off always results in fixedMid though.

I want it to be fixedMid when on, fixedBottom when off. I’m probably missing a little something?

When presence is off, the message still comes out the top output?

Flipping the boolean does not update the current state I think.

Does the status of the node below say off?


All states should be immediately updated.

It doesn’t update at all. It sees the state when I deploy the flow and stays there.

You need to trigger the flow try putting a inject node before the current state to test it. Turn the boolean on inject. You should see a green staus with on.

Turn off presence hit the inject again, it should be red with off.

I assume that the hvac is independently controlled. So in your instance you would already be in the kitchen, hvac turns on it then goes to mid.

You would need another automation to change the heating mode if the hvac was on and then you entered the kitchen.

Just gave it a try. Still no dice. It reads the state when deploying and stays there.

You are pressing the little grey button to the left of the inject?

This changes the entire message to “fixedBottom”.

That is because the inject node does not send the same information as the ac node. It can’t change a message that is not there. Turn the ac on and off and the message will be correct.

msg topic isn’t there


Restarting the flow on state change would work just fine I think? When I do that by hand it works.