Garbage Collection Reminder


#1

I realize this piston will need to be redone and customized by each person to fit their own collection schedule, here is mine…
Trash collection is every other weekday (except holidays), recycling is every Monday (only on collection days).

This piston will fire every night at 1am and check an HTTP endpoint to see if today is a national observing holiday. It will then calculate if today is trash and/or recycling pickup day and display as piston status. You can also easily add a push notification if you’d like.
The HTTP url endpoint is:
http://holidayapi.riccardoravaro.com/api/v1/holidays?country=US&year={$year}&month={$month}&day={$day}


Solution - Echo Alarm Clock Like Reminder
Bin days idea (UK)
String to Date?
#2

HA! Awesome piston!!

I did essentially the same thing in Tasker a couple years ago. It announces the appropriate trash for the appropriate day:
Monday = garbage and yard waste
Wednesday = garbage and recycling
Friday = garbage and rubbish.

It announces at 6:30am on the appropriate morning… unless that day is a holiday, in which case it is silent.
It also looks ahead. Ask the weekend before LaborDay or MLK Day or President’s Day “what is the next garbage?” and it will reply correctly “Wednesday, garbage and recycling”.


#3

Any way to modify that URLGET with tomorrow date?

I modified the piston to alert me the night before at 9pm (changed the days appropriately etc)

But I can’t figure out how to get it to check the holiday for tomorrow instead… I thought of creating a variable and using that, but the problem is when the holiday falls on the last day of the month


#4

Very cool, but that API is incomplete. My trash is also bumped out by state holidays. Do you know if his API has a state handle and state level data? Did you find a manual for his API - I did not find when when looking. I tried adding “&state=XX” right after the country, but no luck.


#5

You guys get trash pickup every other day?! Once a week here, trash + recycle one week, trash + greens the next.

I barely have 1/4 of a trash can full to pick up even once a week, can’t imagine needing pickup every other day.


#6

Same. I modified it for trash once a week, recycle every other week if you want my piston


#7

@elmetal - yes please! Thanks!


#8

Does it include holidays as well? Here the schedule is one day later if there is an observed holiday any day of the week before or including the pickup day. I tried to incorporate that but once I realized that I would have to deal with querying for days in the previous month I gave up…


#9

It doesn’t include the holiday because I haven’t figured out how to check tomorrow’s date for the holiday calendar.

So I’ll post it here and you’ll see what I mean. So at 9pm on monday nights, it tells me trash/recycling is due tuesday.

so if you only get it once a week and recycling is every other week like me, just adjust the variable for day of the week to match your trash pickup day. I get picked up tuesday and get alerted monday night. Hence why it’s hard to get the holiday. I could easily fix it if I just alert myself tuesday morning, but I don’t work every tuesday and I hate getting up early for the trash so :slight_smile:

If anyone has any idea how I can check tomorrow’s date with the api that’d be swell. I tried $day + 1, but if the holiday is at the end of the month, I’m hosed. Although… there are no holidays on the 30/31 are there?


#10

addDays($now, 1) for tomorrow and -1 for yesterday should do the trick. formatDateTime can help you get a specific component of the date. More details


#11

Perfect, @elmetal! My pickup day is Tuesday as well! :slight_smile:

I’ll wait a bit to see if the info from @ipaterson helps you incorporate holidays.


#12

sounds good!

if the recycling is off a week for you, just change the time of the piston and run it once out of order and set it back to normal.

I should’ve made a way so that if you test it, it flips the switch for ya but I didn’t actually plan to share it since I figured the original would fit more people’s schedules!


#13

Did the piston not paste?


#14

Awesome - I’ll take a stab at it (totally forgot about both, addDays() and formatDateTime())…


#15

I love the idea of a “night before” reminder, I wonder if I have the Piston constantly checking the endpoint for tomorrow and storing today in a variable. Working on it.
Also, in my neighborhood we have a phone number we can text to have them come for a special items pickup. I wonder if I use a tile action to trigger sending an SMS!!


#16

OK – almost there.

Current issues:

  • formatDateTime() doesn’t give the option to return the day of the week as a number —I worked around this using a switch statement but it is ugly…
  • $response.holidays.name returns an array (e.g., look at the result for http://holidayapi.riccardoravaro.com/api/v1/holidays?country=US&year=2018&month=1&day=1) — I’m pretty sure the “is any of” in the piston of the original posting won’t work correctly. @ipaterson: any smart idea on how to find if two string lists have at least one intersecting item (without having to iterate each time)?

Off to a parent meeting now but I’ll resume later tonight…


#17

contains supports list as a haystack but not the needle. this would require 1 iteration with the second string list at a minimum.


#18

If you’re just dealing with yesterday and tomorrow you could make use of $dayOfWeek instead. Tomorrow will be ($dayOfWeek + 1) % 7 and yesterday will be ($dayOfWeek + 7 - 1) % 7 (left the explicit + 7 to make it obvious that it is avoiding negatives)


#19

@ahndee i was going to ask the same question how are you using day of week? if you are not dealing with yesterday or tomorrow heres one way to do it without switch:

(indexOf(‘SunMonTueWedThuFriSat’, EEE) / 3)

returns 0 for Sunday, 1 for Monday and so on.


#20

Oh that’s very clever!