Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: days on sun events #20

Open
gpongelli opened this issue Aug 10, 2020 · 2 comments
Open

Feature: days on sun events #20

gpongelli opened this issue Aug 10, 2020 · 2 comments
Labels
enhancement New feature or request

Comments

@gpongelli
Copy link

Hi, congratulations for this node, it's very powerful!

Using it I've found that could be useful adding a day/month/year selection, like cron does, applied on sunrise/sunset events to fire message on events like "weekend sunset" or "march sunrise" and so on.
Do you think it can be feasible ?

Thanks!

@Steve-Mcl
Copy link
Owner

Hi @gpongelli , thanks for the compliments.

I've found that could be useful adding a day/month/year selection, like cron does, applied on sunrise/sunset events
This is something that has entered (and quickly left) my head when I was adding solar times.

I will leave this open and if i have a genius idea of how to chain the cron and solar events, I will update you.

For now, I can only offer you a workaround...

weekend sunset / march sunrise

image

[{"id":"f48678de.0f5e48","type":"cronplus","z":"30b25d3f.3e99f2","name":"sunrise","outputField":"payload","timeZone":"","persistDynamic":false,"commandResponseMsgOutput":"output1","outputs":1,"options":[{"name":"schedule1","topic":"schedule1","payloadType":"default","payload":"","expressionType":"solar","expression":"0 * * * * * *","location":"54.80385112692028 -1.58203125","offset":"0","solarType":"selected","solarEvents":"sunrise"}],"x":120,"y":540,"wires":[["d3ade435.4fa688"]]},{"id":"66fb6941.833ad8","type":"debug","z":"30b25d3f.3e99f2","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":470,"y":540,"wires":[]},{"id":"d3ade435.4fa688","type":"switch","z":"30b25d3f.3e99f2","name":"Is March","property":"$parseInteger( $fromMillis(payload.triggerTimestamp, '[M]'), \"10\" )","propertyType":"jsonata","rules":[{"t":"eq","v":"3","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":280,"y":540,"wires":[["66fb6941.833ad8"]]},{"id":"8340829a.b599a","type":"cronplus","z":"30b25d3f.3e99f2","name":"sunset","outputField":"payload","timeZone":"","persistDynamic":false,"commandResponseMsgOutput":"output1","outputs":1,"options":[{"name":"schedule1","topic":"schedule1","payloadType":"default","payload":"","expressionType":"solar","expression":"0 * * * * * *","location":"54.80385112692028 -1.58203125","offset":"0","solarType":"selected","solarEvents":"sunset"}],"x":110,"y":480,"wires":[["d498ceff.44242"]]},{"id":"28544799.e76238","type":"debug","z":"30b25d3f.3e99f2","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":470,"y":480,"wires":[]},{"id":"d498ceff.44242","type":"switch","z":"30b25d3f.3e99f2","name":"Is Weekend","property":"$fromMillis(payload.triggerTimestamp, '[F]')","propertyType":"jsonata","rules":[{"t":"eq","v":"saturday","vt":"str"},{"t":"eq","v":"sunday","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":290,"y":480,"wires":[["28544799.e76238"],["28544799.e76238"]]}] 

@Steve-Mcl Steve-Mcl added the enhancement New feature or request label Aug 22, 2020
@drmibell
Copy link

drmibell commented Dec 5, 2020

With a very small tweak to @Steve-Mcl's workaround, you can define filters simply by how you wire them into your flow. You can even stack them to select odd-numbered Thursdays in November, and so on.
image

[{"id":"ef43332c.9bf5f","type":"inject","z":"ba1ce897.641f8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":120,"y":120,"wires":[["4704b020.79f358"]]},{"id":"4704b020.79f358","type":"switch","z":"ba1ce897.641f8","name":"day","property":"$fromMillis($millis(),'[FNn]')","propertyType":"jsonata","rules":[{"t":"eq","v":"Sunday","vt":"str"},{"t":"eq","v":"Monday","vt":"str"},{"t":"eq","v":"Tuesday","vt":"str"},{"t":"eq","v":"Wednesday","vt":"str"},{"t":"eq","v":"Thursday","vt":"str"},{"t":"eq","v":"Friday","vt":"str"},{"t":"eq","v":"Saturday","vt":"str"}],"checkall":"false","repair":false,"outputs":7,"x":270,"y":120,"wires":[[],["439d1fcd.29c44"],[],["439d1fcd.29c44"],[],["439d1fcd.29c44"],[]]},{"id":"439d1fcd.29c44","type":"debug","z":"ba1ce897.641f8","name":"m,w,f","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":430,"y":120,"wires":[]},{"id":"75de3ae5.8e3aac","type":"switch","z":"ba1ce897.641f8","name":"month","property":"$fromMillis($millis(),'[MNn]')","propertyType":"jsonata","rules":[{"t":"eq","v":"January","vt":"str"},{"t":"eq","v":"February","vt":"str"},{"t":"eq","v":"March","vt":"str"},{"t":"eq","v":"April","vt":"str"},{"t":"eq","v":"May","vt":"str"},{"t":"eq","v":"June","vt":"str"},{"t":"eq","v":"July","vt":"str"},{"t":"eq","v":"August","vt":"str"},{"t":"eq","v":"September","vt":"str"},{"t":"eq","v":"October","vt":"str"},{"t":"eq","v":"November","vt":"str"},{"t":"eq","v":"December","vt":"str"}],"checkall":"false","repair":false,"outputs":12,"x":590,"y":120,"wires":[[],[],[],[],[],[],[],[],[],[],[],[]]},{"id":"c1f6c178.4390f8","type":"switch","z":"ba1ce897.641f8","name":"odd/even","property":"$number($fromMillis($millis(),'[D]')) % 2","propertyType":"jsonata","rules":[{"t":"eq","v":"0","vt":"num"},{"t":"gt","v":"0","vt":"num"}],"checkall":"false","repair":false,"outputs":2,"x":760,"y":120,"wires":[[],[]]}]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants