Gpio mqtt button light

Hi
i’m new i want know a solution on a problem

USE CASE
I have a central raspberry node that use as a cntral pannel for use alla my house
then
when i push a button on a central send a message mqtt on client node1
node 1 receive a message and make this action
read pin 16 is on and put this to off
or
read pin 16 is off and put this to on
then send a message mqtt with result to central
central read mqtt and if is on turn on led otherwise off

is a simple flow for push a putton for turn on the light anche this go to on or to off and send to central panel last lamp state

but

with a object in the toolbar is impossible design this flow
and if i try to read pin 16 and after many block i try to write same pin
the flow have a problem

any idea

If I understand correctly you are trying to read the state of a pin that is configured as an output. You can't do that, you can only write to an output and read from an input. Why to you need to read a pin that is an output?

neodev

If I understood well you wanted just to toggle a pin when you receive the mqtt message, there are may ways to do it but I recommend you try to install from your pallete “node-red-contrib-smartswitch” .

After this you will get a smartwitch new node eon the palette, as soon as you pull any message with a “toggle” value as topic you will have the out changing directly from 1 to 0 and vice versa.

Regards

I wanted to have a push button on the raspberry 1
a relay that turns on the lights on the raspberry 2
use mqtt to communicate to node 2 that the button has been pressed
problem to be solved
if I press the button on node 1
node 2 if the lights were on it must turn them off if the lights were off the must turn on.
so its behavior depends on the state in which the relay was previously but how do I read in what state was the relay if an out pin can not read the current state

because you are in control of the out pin (I hope) - then you already know the state that you last set it to.

Please check twice what I wrote you and test it, this node will allow you to make very easy the toggle function.

Regards