Garbage Collection Reminder


#21

When this is ready to share, can someone help me w/the restore piston process?

I was “practicing” importing using the import code from above, M672, and not sure about steps to restore missing content after the import. When the import is being completed I’m asked to provide a URL so I use http://holidayapi.riccardoravaro.com/api/v1/holidays?country=US&year={$year}&month={$month}&day={$day} from above, and end up with this below.

Just confirming that I’m doing it correctly…


#22

Awesome - that’ll do. I need it to iterate over all days before the pickup day and to minimize processing for the rest of the week after pickup day.

Edit: On second thought, I can just use $dayOfWeek :man_facepalming:


#23

OK – I’m pretty sure that this piston is doing what I want:

  1. Weekly trash pickup, bi-weekly recycling pickup
  2. Piston state shows day when pickup is happening this week (or whether it has already passed) and what is going to be picked up
  3. Sends a notification the night before the scheduled pickup
  4. If an observed holiday falls in the week on any day before and including the normally scheduled pickup day, the pickup changes to the following day


Edit: I’m aware that iterating over observedHolidays rather than $response.holidays.name is less efficient. However, the latter somehow contained some leading whitespace character for items other than the first which did not get removed using trim() (this might be a bug in webCoRE but the current implementation seems to do the job).


#24

yeah $dayOfWeek works if you can start from today and go forward or backwords.


#25

So how would you handle trash pickup twice per week.


#26

Is there a downside to your changes hitting the endpoint 7 times a day? I only mention because this guy is nice enough to host this open script and I dont want him to remove it!


#27

It looks like you only put in certain holidays at the top of your piston…Does this mean only on those days the service moves to the next day? Trying to figure out which fields I need to fill in/modify…
Which lines should I remove/modify if I don’t need the recycling notification?


#28

You could just run two instances of the piston, one for each pickup day.

Fair point – I’ll rework the piston to only query once a week. However, it won’t check 7 times a day; it only checks for each weekday up to and including your scheduled pickup day and bails out as soon as it encounters a holiday. It won’t check at all on days of the week after your scheduled pickup day.

Yes - the days listed are the only ones that cause a day to be skipped here. You can just edit the observedHolidays variable declaration to match your local schedule.

You can just default the isRecyclingWeek to false in the variable declaration.


#29

OK – reworked piston to only check for holidays once a week (and some other cleanup/optimizations):

After importing, use the following in the expression field for the Make GET request:

format('http://holidayapi.riccardoravaro.com/api/v1/holidays?country=US&year=%s', formatDateTime(addDays($now,$index),"y'&month='M'&day='d"))

#30

I guess my thought process would be you would create a second variable (ie. pickup 2) but then you would need to re-work your ‘if’ statement to exclude two numbers (ie. 1 and 4). BUT then I guess you would have to adjust the action for each variable.


#31

minor request, can you please update your piston states to print in bold format? At least the one reporting trash/recycling is date - vs for example, the one ‘no more collection this week’.


#32

Which line do I change for the isrecycling false?

Also, the GET request URL was in the piston…but now it’s gone…want me to sure I use the correct one…(Tried to put in http://holidayapi.riccardoravaro.com/api/v1/holidays?country=US&year={$year}&month={$month}&day={$day} but it rejected it as an error)

For the send notification, I tried to change it from (text?) to email, but I lost all the variables you set up…


#33

Line 24 in the above piston (import code yaj6)

It’s still there in line 48 – it just uses an expression rather than a value so that it can change the request days on the fly.

Just re-import the piston and copy the expression before changing the step, then paste into the email.


#34

If you wouldn’t mind, would it be possible to create another piston, please, with no recycling notification and email notification instead?

I’m trying to work with the other one…but I am just messing it up more…lol


#35

@ahndee: Is there a simple way to modify your piston to have Trash/Recycle one week, Trash/Greens the next, and so on? (Greens=lawn clippings, etc.)

Thanks.


#36

Yes - in lines 60 and 64, change the '' after ' and ♻️ Recycling' : to ' and 🌿 Greens'


#37

I probably don’t understand…but if I replace “recycling” with “Greens,” won’t that just change recycling to greens?

I need to have both of them…

Week1: Trash + Recycling
Week2: Trash + Greens
Week3: Trash + Recycling
Week4: Trash + Greens

Etc.

Maybe I didn’t understand the edit you were suggesting - is this it?

format(‘:wastebasket:️ Trash%s pickup on %s.’, isRecyclingWeek ? ’ and :recycle:️ Recycling’ : ’ and :herb: Greens’, formatDateTime(addDays($now, pickupDay-$dayOfWeek + (isHoliday ? 1 : 0)),‘EEEE’))


#38

Yes - that’s what I understood and using the above change will achieve that. As noted you should change the '' (empty string) after the recycling string.


#39

Yes - that is correct. There is a minor optimization could could be done though (avoiding repeating the “and”):

format('🗑 Trash and %s pickup on %s.', isRecyclingWeek ? '♻️ Recycling' : '🌿 Greens', formatDateTime(addDays($now, pickupDay-$dayOfWeek + (isHoliday ? 1 : 0)),'EEEE'))

#40

Ah, yes, I see.

Cool…I’ve made the edits, we’ll see how it goes.

One final Q - what’s the best way to initialize the “isRecyclingWeek” variable to “true” for this week?

I’m not familiar w/initializing variables.