Thoughts on creating trash day reminder?

I want to create flow to have Alexa remind when its trash day / trash recyclable day.

Pickups are always on Wednesdays and it alternates between being trash only or trash + recyclables.

Having a hard time trying to come up with a flow that would lead to 2 different speak nodes. One to tell us “today is trash only” and “today is trash and recyclables”.

Like how do I get it to alternate between the two? Short of inputting every specific day into a scheduler node.

What Im thinking in my head but cant put thought to paper is (assuming today is wednesday) have a flow that says trigger the trash only speak node, then in 7 days trigger the trash+ speak node, then in another 7 trigger the trash only.

I hope this makes sense to someone lol.

Edit.
Heres what i came up with. It works but still looking for improvements…

  • I have to initially set the global variable global.trash, the first time
  • Wed at 7am it will check the global variable and see if its set to “trash only” or “trash+” and then speak the corresponding message through Alexa. At the same time it will also then toggle the variable to the other one, so that next Wednesday it is correct.

Couple downsides to this though:

  1. If HA is not up at 7AM on Wed, it wont run and therefore wont switch for next week.
  2. If I have to restart my host, I believe I lose all global variables and it would need to be reset.

I assume node red?
Use the date time formatter, can’t remember the name of the node, but it can give you week number.
If week number is even or uneven

yes node red, I thought I put this in the node red sub. Maybe I didnt…

I just built this for myself because i forgot the trash last week :slight_smile:
at 8:30pm on garbage night, announce to our speaker system, it’s garbage night. then i send a notification to my phone saying so, with actionable notifications, about reminding me in 30m or not. if i say remind me, another notification is send, if i say i’m good, then a stern message about why this was created in the first place is sent to me

The inject node goes off every thursday. Make an input boolean toogle that then switches it to the other output next time.

[{"id":"dac6287f.0455b","type":"inject","z":"d6a46901.ebee1","name":"Every wednesday","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"00 12 * * 3","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":440,"y":360,"wires":[["40b544d8.f8137c"]]},{"id":"40b544d8.f8137c","type":"api-current-state","z":"d6a46901.ebee1","name":"","server":"","version":1,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"input_boolean.garbage_reminder","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":760,"y":360,"wires":[["89853c91.7be718"],["2a2d57ca.08e44"]]},{"id":"89853c91.7be718","type":"api-call-service","z":"d6a46901.ebee1","name":"","server":"","version":1,"debugenabled":false,"service_domain":"switch","service":"turn_off","entityId":"input_boolean.garbage_reminder","data":"","dataType":"jsonata","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1150,"y":340,"wires":[[]]},{"id":"2a2d57ca.08e44","type":"api-call-service","z":"d6a46901.ebee1","name":"","server":"","version":1,"debugenabled":false,"service_domain":"switch","service":"turn_on","entityId":"input_boolean.garbage_reminder","data":"","dataType":"jsonata","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1150,"y":380,"wires":[[]]}]
1 Like

Have you seen this Garbage Collection custom component before? Maybe you can use it, or give you some ideas. It is available on HACS.

bruxy70/Garbage-Collection: :wastebasket: Custom Home Assistant sensor for scheduling garbage collection (or other regularly re-occurring events - weekly on given days, semi-weekly or monthly) (github.com)

2 Likes

There’s also the “recollect” integration (not custom). If your city uses their platform you can easily add a sensor.

1 Like

And perhaps scheduler node can help you with the weekdays so you dont have to set them.

This is how I do it, It just checks if the week number (from epoch time) is even or odd.

[{"id":"aca5d241.720ec","type":"inject","z":"5f64b721.e82e98","name":"Bins out (Tuesday)","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"00 05 * * 2","once":false,"onceDelay":0.1,"x":150,"y":2320,"wires":[["596d6874.5747d8"]]},{"id":"596d6874.5747d8","type":"function","z":"5f64b721.e82e98","name":"Even or odd week?","func":"// get week number\nvar num = msg.payload/604800000; \n\n// is week even or odd\nmsg.payload = parseFloat(num.toFixed(0)) % 2 ;\n\n// return 0 or 1\nreturn msg;\n\n","outputs":1,"noerr":0,"x":370,"y":2320,"wires":[["752e1d02.588d64"]]},{"id":"752e1d02.588d64","type":"switch","z":"5f64b721.e82e98","name":"Even/odd","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"str"},{"t":"eq","v":"1","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":560,"y":2320,"wires":[["d87776c1.bbf5b8"],["41bcd50d.214bac"]]},{"id":"38427428.c9ec4c","type":"comment","z":"5f64b721.e82e98","name":"Bin notification","info":"","x":140,"y":2220,"wires":[]},{"id":"abe6efcd.6959c","type":"inject","z":"5f64b721.e82e98","name":"Clear Bins (Wednesday)","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"00 05 * * 3","once":false,"onceDelay":0.1,"x":170,"y":2400,"wires":[["4f86c600.738a2c"]]},{"id":"4c797fc0.6ee1c","type":"comment","z":"5f64b721.e82e98","name":"Recycling/Green","info":"","x":560,"y":2360,"wires":[]},{"id":"4f86c600.738a2c","type":"api-call-service","z":"5f64b721.e82e98","name":"Set bins none","server":"","version":1,"debugenabled":false,"service_domain":"input_select","service":"select_option","entityId":"input_select.bins","data":"{\"option\":\"None\"}","dataType":"json","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":760,"y":2400,"wires":[[]]},{"id":"d87776c1.bbf5b8","type":"api-call-service","z":"5f64b721.e82e98","name":"Set bins recycling","server":"","version":1,"debugenabled":false,"service_domain":"input_select","service":"select_option","entityId":"input_select.bins","data":"{\"option\":\"Recycling\"}","dataType":"json","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":770,"y":2300,"wires":[[]]},{"id":"41bcd50d.214bac","type":"api-call-service","z":"5f64b721.e82e98","name":"Set bins garden","server":"","version":"1","debugenabled":false,"service_domain":"input_select","service":"select_option","entityId":"input_select.bins","data":"{\"option\":\"Garden\"}","dataType":"json","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":760,"y":2340,"wires":[[]]},{"id":"3a167df0.4b44b2","type":"inject","z":"5f64b721.e82e98","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":560,"y":2280,"wires":[["41bcd50d.214bac"]]},{"id":"a557e173.f6b8d","type":"inject","z":"5f64b721.e82e98","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":560,"y":2240,"wires":[["d87776c1.bbf5b8"]]}]
2 Likes

You could actually make that more compact with this function node:

// get week number
var num = msg.payload/604800000; 

// is week even or odd
if (parseFloat(num.toFixed(0)) % 2 == 0) {
    return [[msg],null];
}else{
    return [null,[msg]];
}

and set it to two outputs

2 Likes

Thanks, that’s a good simplification

Thanks for all the ideas guys!

can you export this flow for me please?? :slight_smile: