node-red-contrib-schedex icon indicating copy to clipboard operation
node-red-contrib-schedex copied to clipboard

On and off switched

Open Boss-man opened this issue 5 years ago • 4 comments

Maybe not the best title, but here goes:

I'm using ontime: dusk and off time 22:00. Works great in the winter, but here in the summer, dusk is actually later than 22:00, resulting in OFF at 22.00 and ON at dusk, leaving my lights on the whole night.

In this case, it should just keep off at all time.

Boss-man avatar May 30 '19 16:05 Boss-man

This isn't as straightforward as it sounds. Schedex doesn't know if you want dusk to 22:00 the following day.

To be able to work this out we'd have to conceive some form of same day mode? Dunno, I'll have to think it through.

biddster avatar Jun 05 '19 18:06 biddster

Maybe this is similar to #79. I think this could be done if you could just configure a latest time for the on command of 22:00 ? What would be the reaction of schedex with on time and off time defined to the same time?

pkess avatar Dec 09 '20 11:12 pkess

Here is an example using node-red-contrib-time-range-switch

It will only allow to switch on between 14 and 21:50. So the lights will not be turned on for less than 10 minutes

[{"id":"e516dc16.a4ad5","type":"tab","label":"Flow 2","disabled":false,"info":""},{"id":"26de35b7.037fba","type":"time-range-switch","z":"e516dc16.a4ad5","name":"","lat":"","lon":"","startTime":"14:00","endTime":"21:50","startOffset":0,"endOffset":0,"x":590,"y":380,"wires":[["a98d4b1d.2cc7f8"],[]]},{"id":"a98d4b1d.2cc7f8","type":"debug","z":"e516dc16.a4ad5","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":881,"y":350,"wires":[]},{"id":"66aa914b.5d877","type":"schedex","z":"e516dc16.a4ad5","name":"","passthroughunhandled":false,"suspended":false,"lat":"","lon":"","ontime":"","ontopic":"","onpayload":"","onoffset":0,"onrandomoffset":0,"offtime":"22:00","offtopic":"Off","offpayload":"Off","offoffset":0,"offrandomoffset":0,"mon":true,"tue":true,"wed":true,"thu":true,"fri":true,"sat":true,"sun":true,"x":390,"y":380,"wires":[["26de35b7.037fba"]]},{"id":"2520d6cb.83834a","type":"schedex","z":"e516dc16.a4ad5","name":"","passthroughunhandled":false,"suspended":false,"lat":"","lon":"","ontime":"dusk","ontopic":"on","onpayload":"on","onoffset":0,"onrandomoffset":0,"offtime":"","offtopic":"","offpayload":"","offoffset":0,"offrandomoffset":0,"mon":true,"tue":true,"wed":true,"thu":true,"fri":true,"sat":true,"sun":true,"x":390,"y":300,"wires":[["a98d4b1d.2cc7f8"]]}]

pkess avatar Dec 09 '20 11:12 pkess

I also run into this situation. This must be a rather common situation. I'm surprised it doesn't surface more often. I solved it using the node-red-contrib-time-range-switch as suggested but it's messy and potentially hard to maintain. See example below.

I think it could make sense to only fire the on event if there is no scheduled off time for the node or if the scheduled off time is in the future. That would make sense if you schedule lights. I'm sure someone has a use case for the current behaviour so an option to check for a scheduled future off time would be great.

[{"id":"76942900.8715b8","type":"schedex","z":"e3172c0a.a249c","name":"","passthroughunhandled":false,"suspended":false,"lat":"56.3159","lon":"12.7694","ontime":"","ontopic":"","onpayload":" {"On":true}","onoffset":"-30","onrandomoffset":true,"offtime":"sunriseEnd","offtopic":"","offpayload":" {"On":false}","offoffset":"30","offrandomoffset":true,"mon":true,"tue":true,"wed":true,"thu":true,"fri":true,"sat":true,"sun":true,"x":290,"y":180,"wires":[["7b26dee8.59b3"]]},{"id":"794030d1.a9416","type":"inject","z":"e3172c0a.a249c","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"on","payloadType":"str","x":110,"y":120,"wires":[["d88253f7.d21748"]]},{"id":"7b26dee8.59b3","type":"json","z":"e3172c0a.a249c","name":"","property":"payload","action":"","pretty":false,"x":530,"y":180,"wires":[["50d93267.590724","9d485bb8.6101f","b5da80e.97afc8","a3000652.7473e","23d03e66.b974ca","19683998.5ed3b6"]]},{"id":"42a03237.eaec9c","type":"inject","z":"e3172c0a.a249c","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"off","payloadType":"str","x":110,"y":180,"wires":[["76942900.8715b8"]]},{"id":"ee4fe27b.ddc7b","type":"schedex","z":"e3172c0a.a249c","name":"","passthroughunhandled":false,"suspended":false,"lat":"56.3159","lon":"12.7694","ontime":"sunsetStart","ontopic":"","onpayload":" {"On":true}","onoffset":"30","onrandomoffset":true,"offtime":"","offtopic":"","offpayload":" {"On":false}","offoffset":"30","offrandomoffset":true,"mon":true,"tue":true,"wed":true,"thu":true,"fri":true,"sat":true,"sun":true,"x":270,"y":360,"wires":[["5922b3d8.9ad764"]]},{"id":"27ed7806.dfacb8","type":"comment","z":"e3172c0a.a249c","name":"Utebelysning","info":"","x":130,"y":60,"wires":[]},{"id":"a1904971.61077","type":"time-range-switch","z":"e3172c0a.a249c","name":"","lat":"56.3159","lon":"12.7694","startTime":"1:00","endTime":"sunriseEnd","startOffset":0,"endOffset":"-40","x":470,"y":60,"wires":[["7b26dee8.59b3"],[]]},{"id":"d88253f7.d21748","type":"schedex","z":"e3172c0a.a249c","name":"","passthroughunhandled":false,"suspended":false,"lat":"56.3159","lon":"12.7694","ontime":"6:30","ontopic":"","onpayload":" {"On":true}","onoffset":"-30","onrandomoffset":true,"offtime":"","offtopic":"","offpayload":" {"On":false}","offoffset":"30","offrandomoffset":true,"mon":true,"tue":true,"wed":true,"thu":true,"fri":true,"sat":true,"sun":true,"x":270,"y":120,"wires":[["a1904971.61077"]]},{"id":"5922b3d8.9ad764","type":"time-range-switch","z":"e3172c0a.a249c","name":"","lat":"56.3159","lon":"12.7694","startTime":"11:00","endTime":"22:00","startOffset":0,"endOffset":0,"x":450,"y":360,"wires":[["7b26dee8.59b3"],[]]},{"id":"246317d4.80cbd","type":"schedex","z":"e3172c0a.a249c","name":"","passthroughunhandled":false,"suspended":false,"lat":"56.3159","lon":"12.7694","ontime":"","ontopic":"","onpayload":" {"On":true}","onoffset":"30","onrandomoffset":true,"offtime":"22:00","offtopic":"","offpayload":" {"On":false}","offoffset":"45","offrandomoffset":true,"mon":true,"tue":true,"wed":true,"thu":true,"fri":true,"sat":true,"sun":true,"x":280,"y":300,"wires":[["7b26dee8.59b3"]]}]

Sastrugisnow avatar May 27 '21 09:05 Sastrugisnow