Update helper status without triggering

Hi,

I have an input boolean helper which I use to control something through Node-RED. If I switch it on, flow A is triggered and turns the device on, if I switch it off, flow B is triggered and turns the device off.

So far so good.

However, the device I am controlling can also be switched on/off by other means. I have also means to track the status through Node-RED.

What I am missing however, is a way to update the state in Home Assistant through Node-RED without triggering a new state change event.

While in many cases it might not matter much, especially if you run timed events based on the state switch, things can deliver unwanted results…

I migrated from OpenHAB where this could relativly easily be achived with the nodes having options for “command” and “update”. Is this functionality really not available or am I just looking in the wrong places?

1 Like

You might have to reverse it a bit.

Right now you have an automation that triggers the scripts when the boolean helper change state.
Remove that automation and then have the script set the boolean helper as part of the script.

1 Like

Hmm, I am not sure how this would work. In that case I would use the function of manually turning on/off the switch myself, which is of course the core functionality…

Of course I could introduce a second helper (or a variable in Node-RED) and compare the real state with the intended state - but that doesn’t strike me as a particulary elegant solution.

I tried writing directly to the homeassistant global object, which does work - but changes nothing on the HA-side…

In HA the state change will always trigger the automation.
You can of course disabled the automation, then make the state change and then reenable the automation again.

Still the correct way would be to move the unlink the script, since it seems to be not wanted to run on all state changes,

postUpdate is the only thing I am missing from my times with openHAB

So the automation when switched on by something other than NR, you want to turn on the boolean that would trigger the flow in NR but not trigger that flow in NR? Sounds like you need a current state node.

image

With the current state, when the flow is triggered to turn the light on, it first checks if the light is already on. If it is on the flow stops there and does not perform the action, if it is off then the action would execute.

I guess this is not available in “regular” UI automations, but in NR only?

It is, in the UI this would be a condition. If you create a new automation, the 2nd section ‘And if’ there is a button with + add condition.