Master slave setup with two conditions

Hello together

I'm pretty new with node red and all this stuff, so please have this in mind.. :wink:
I want to set up a smart home solution with an rpi4 and a zigbee controller.
What I am looking for at the moment is a master/slave solution which accounts for
another condition but only the master.
I want to have a wifi socket that switches on if another socket is powered but (i.e. AND) only at nighttime.
The sockets are TPLink HS110, which can measure as well. So I get the power value from the master socket and switch the slave socket accordingly. So this is working.
For the nighttime-condition there is a flow which works in a simple test setup to create nodes
in relation to the time. So this works (in principle) as well.
Now I have to combine these two and this is where I am stuck.
I downloaded some other flows with an AND logic.
I tried with an inject node that checks every three seconds if a) the socket is powered and b) it is at nighttime. Afterwards both conditions should be comparted in the AND logic to switch the slave socket. But so far I could not get it running, and I've noticed that it tries to alter the status of the socket in the 3 second frequency even though there is no change.
So I figured the most logical way was that the nighttime query determines a variable and that this is taken into account for the power status of the slave socket.
Does this make any sense?
Anyway I am grateful for any working hint.



Hi and welcome.

It would be best to export your flow so others can see it. Others may not have zigbee or tplink, so best to add inject nodes holding the output from the devices (i.e the on/off output , captured by a debug node )and the format and values of the input to controll the socket. The more info you can give the easier it is to help. Remember images are ok to see, but text is better as it can be copied and pasted easily.

also when adding code best to follow instructions here so code is no corrupted

An idea could be to use the "gate" node in combination with the "bigtimer" node.
The bigtimer sets the gate node to open/close, depending on the day time.
You put the gate node into your flow to to stop messages from passing on during the day and letting them through during night time.

[{"id":"d4302e1e.2383d","type":"bigtimer","z":"29645592.a8b5ea","outtopic":"control","outpayload1":"","outpayload2":"","name":"Dawn/Dusk","comment":"","lat":0,"lon":0,"starttime":"5000","endtime":"5001","starttime2":0,"endtime2":0,"startoff":0,"endoff":0,"startoff2":0,"endoff2":0,"offs":0,"outtext1":"open","outtext2":"close","timeout":1440,"sun":true,"mon":true,"tue":true,"wed":true,"thu":true,"fri":true,"sat":true,"jan":true,"feb":true,"mar":true,"apr":true,"may":true,"jun":true,"jul":true,"aug":true,"sep":true,"oct":true,"nov":true,"dec":true,"day1":0,"month1":0,"day2":0,"month2":0,"day3":0,"month3":0,"day4":0,"month4":0,"day5":0,"month5":0,"day6":0,"month6":0,"day7":0,"month7":0,"day8":0,"month8":0,"day9":0,"month9":0,"day10":0,"month10":0,"day11":0,"month11":0,"day12":0,"month12":0,"d1":0,"w1":0,"d2":0,"w2":0,"d3":0,"w3":0,"d4":0,"w4":0,"d5":0,"w5":0,"d6":0,"w6":0,"xday1":0,"xmonth1":0,"xday2":0,"xmonth2":0,"xday3":0,"xmonth3":0,"xday4":0,"xmonth4":0,"xday5":0,"xmonth5":0,"xday6":0,"xmonth6":0,"xd1":0,"xw1":0,"xd2":0,"xw2":0,"xd3":0,"xw3":0,"xd4":0,"xw4":0,"xd5":0,"xw5":0,"xd6":0,"xw6":0,"suspend":false,"random":false,"randon1":false,"randoff1":false,"randon2":false,"randoff2":false,"repeat":true,"atstart":true,"odd":false,"even":false,"x":470,"y":300,"wires":[[],[],["3e68b2e1.a9f666"]]},{"id":"3e68b2e1.a9f666","type":"gate","z":"29645592.a8b5ea","name":"","controlTopic":"control","defaultState":"open","openCmd":"open","closeCmd":"close","toggleCmd":"toggle","defaultCmd":"default","statusCmd":"status","persist":false,"x":670,"y":240,"wires":[["3fd9b23e.274e76"]]},{"id":"3fd9b23e.274e76","type":"debug","z":"29645592.a8b5ea","name":"slave socket","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":870,"y":240,"wires":[]},{"id":"53a1f6b1.fce1a8","type":"inject","z":"29645592.a8b5ea","name":"master socket","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":460,"y":240,"wires":[["3e68b2e1.a9f666"]]}]

Hey guys thanks for your helpfulness.
But I got it working now! :slight_smile:

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.