Switch on a light with and AND condition

Hello,
I was trying to do an automation that switch on and off a light according to this simple rules:

  1. Swithc on the light if is is dark (between sunset and sunrise)
    AND
  2. Switch on the light if in a specific interval of time

I build up this automation but it looks it doesn't work:

[{"id":"1c6c3860.64b63","type":"bigtimer","z":"45dd8798.2cfc88","outtopic":"EFFEMERIDI","outpayload1":"true","outpayload2":"false","name":"Big Timer","comment":"","lat":"45.6666400","lon":"9.0488400","starttime":"5004","endtime":"5003","starttime2":0,"endtime2":0,"startoff":0,"endoff":"20","startoff2":0,"endoff2":0,"offs":0,"outtext1":"","outtext2":"","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,"xday7":"","xmonth7":"","xday8":"","xmonth8":"","xday9":"","xmonth9":"","xday10":"","xmonth10":"","xday11":"","xmonth11":"","xday12":"","xmonth12":"","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":700,"y":480,"wires":[["2e796d2e.df7ed2"],[],[]]},{"id":"2e796d2e.df7ed2","type":"BooleanLogicUltimate","z":"45dd8798.2cfc88","name":"","filtertrue":"both","persist":true,"sInitializeWith":"WaitForPayload","triggertopic":"trigger","outputtriggeredby":"all","inputCount":2,"topic":"result","x":880,"y":440,"wires":[["a6043f1f.5f1878","525aada2.32f26c"],[],[]]},{"id":"1c190096.45e9ff","type":"bigtimer","z":"45dd8798.2cfc88","outtopic":"ORARIO","outpayload1":"true","outpayload2":"false","name":"Big Timer","comment":"","lat":"45.6666400","lon":"9.0488400","starttime":"360","endtime":"1410","starttime2":0,"endtime2":0,"startoff":0,"endoff":"","startoff2":0,"endoff2":0,"offs":0,"outtext1":"","outtext2":"","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,"xday7":"","xmonth7":"","xday8":"","xmonth8":"","xday9":"","xmonth9":"","xday10":"","xmonth10":"","xday11":"","xmonth11":"","xday12":"","xmonth12":"","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":700,"y":400,"wires":[["2e796d2e.df7ed2"],[],[]]},{"id":"a6043f1f.5f1878","type":"rbe","z":"45dd8798.2cfc88","name":"","func":"rbe","gap":"","start":"","inout":"out","property":"payload","x":1070,"y":500,"wires":[["e3759707.e305b8"]]},{"id":"e3759707.e305b8","type":"switch","z":"45dd8798.2cfc88","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"true","vt":"str"},{"t":"eq","v":"false","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":1190,"y":420,"wires":[["9961feea.ca7998"],["d8e14562.ecb91"]]},{"id":"9961feea.ca7998","type":"api-call-service","z":"45dd8798.2cfc88","name":"Accende luce1 portico","server":"c6e21e6c.847e8","version":1,"debugenabled":false,"service_domain":"homeassistant","service":"turn_on","entityId":"switch.luce1_portico","data":"","dataType":"json","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":1380,"y":400,"wires":[[]]},{"id":"d8e14562.ecb91","type":"api-call-service","z":"45dd8798.2cfc88","name":"Spegne luce1 portico","server":"c6e21e6c.847e8","version":1,"debugenabled":false,"service_domain":"homeassistant","service":"turn_off","entityId":"switch.luce1_portico","data":"","dataType":"json","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":1380,"y":440,"wires":[[]]},{"id":"525aada2.32f26c","type":"debug","z":"45dd8798.2cfc88","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1140,"y":360,"wires":[]},{"id":"c6e21e6c.847e8","type":"server","name":"Casa (local https)","legacy":false,"addon":false,"rejectUnauthorizedCerts":false,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]

Could you help me understanding why?

Do you mean switch it on if it is both dark and and in the interval (so, for example, don't switch it on if it is dark but not in the interval) or do you mean switch it on if it is dark and separately switch it on between the interval? So in that case it will be on if it is dark whether in the the interval or not.

The first is the AND condition of dark and in interval, the second is the OR condition of dark and in interval.

The first one... with the AND because I want to control the darkness with an interval of interest of light saving to keep it switch on continuously.
I expect that 2 Boolean logic block give as output the result of the AND operation but it looks it let come out both ingress values illogically...

If you use big timer to output during the correct time range, then feed that via node-red-contrib-time-range-switch (node) - Node-RED. You can then block the output messages if it is not between dusk / dawn.

It works for me using Inject nodes to simulate the timer.
Add debug nodes showing what is going into the logic node (give them and the other debug nodes names so they can be distinguished) and show us what is going in and out.

1 Like

I misconfigured the switch node because I didn't set it to wait for boolean value "is true" or "is false" but just for a generis string "true" and "false" so it never let the message come trough!

Thank You for your support @Colin

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