Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rpi-locator-logoraspberry-pi-logo

Pi-Restock-Desktop-Notifications

Trying to buy a Pi and use a computer most of your day? Use this to get restock notifications right in your computer's OS when rpilocator.com sees a Raspberry Pi restock.

Why?

I have a lot of projects I want to work on and Raspberry Pis are hard to get ahold of and have been for a while, which is why rpilocator.com came to be. Rpilocator very generously provides a nice RSS feed that provides all stock notifications that the site gets in real time. I wanted the ability to be working throughout the day and have these notifications pop up right on my computer so I can quickly buy when I see it, so I made this app to do just that. It monitors the RSS feed and shows me a native OS notification right on my computer when a new stock message comes up.

Prerequisites

Before running the application, make sure you have the following software installed:

Setup

  1. Clone this repository to your local machine:

    git clone https://github.com/EthyMoney/Pi-Restock-Desktop-Notifications.git

  2. Navigate to the project directory:

    cd Pi-Restock-Desktop-Notifications

  3. Install the project dependencies:

    npm install

  4. (Optional) Customize the behavior — see Configuration below. The defaults watch all models from any vendor in the USA, checked once a minute.

Running the Application

To run the application, simply use the following command: npm start

You should then see a startup notification appear telling you the app is running, this is how you know everything is working and good to go. If you see the notification, you're all set! Now just wait patiently for your restock alert. Press Ctrl+C when you want to stop it.

Clicking a restock notification opens the rpilocator link for that item so you can go buy it.

Configuration

Everything is optional and set through environment variables. Copy .env.example to .env and run with node --env-file=.env index.js, or just set the variables in your shell.

Variable Default Description
PI_FEED_URL https://rpilocator.com/feed/?country=US The feed to poll. Customize for your country, model, vendor, etc. — see the bottom of rpilocator's About Page for the supported parameters.
PI_CHECK_INTERVAL_SECONDS 60 How often to poll. Minimum 30, to stay a good citizen of rpilocator.
PI_REQUEST_TIMEOUT_SECONDS 15 Give up on a single request after this long.
PI_MAX_BACKOFF_SECONDS 900 Ceiling for the retry backoff after repeated failures.
PI_SEEN_CACHE_SIZE 500 How many recently seen items to remember so alerts aren't repeated.
PI_NOTIFY_ON_STARTUP true Show the "app is running" notification on launch.
PI_NOTIFICATION_SOUND false Play the system notification sound.
PI_TITLE_FILTER (none) Case-insensitive regex; only alert when the text matches. e.g. pi 5|cm5.
PI_LOG_LEVEL info One of debug, info, warn, error, silent.

Invalid values are reported at startup rather than silently ignored.

Example — only Pi 5 and CM5 restocks in the UK, checked every two minutes:

PI_FEED_URL='https://rpilocator.com/feed/?country=UK' PI_TITLE_FILTER='pi 5|cm5' PI_CHECK_INTERVAL_SECONDS=120 npm start

How it works

  • Polls the feed on a schedule, tracking items by their feed guid so an item that leaves and re-enters the feed window isn't announced twice.
  • The first poll after launch only seeds that cache, so you don't get a burst of notifications for restocks that already happened.
  • Failed requests retry with exponential backoff up to PI_MAX_BACKOFF_SECONDS, and recovery is logged. A bad feed URL (an HTTP 4xx) exits with an error instead of retrying forever.
  • Ctrl+C stops it immediately, without waiting out the current interval.

Project layout

index.js          startup, poll loop, backoff, shutdown
src/config.js     environment-variable config + validation
src/feed.js       fetch, parse, and normalize the RSS feed
src/notifier.js   desktop notification wrapper
src/seen.js       bounded cache of already-announced items
src/logger.js     timestamped, level-filtered logging

Open Source

License

This project is licensed under the MIT License. See the LICENSE file for details.

Contributing

Contributions are welcome and encouraged! Please feel free to open issues for problems you encounter or feature requests and ideas you come up with. If you would like to contribute code, please open a pull request and describe your changes and reasoning for them. This is a fairly simple app, but there's improvements that can be made and new features that can be added. Thank you in advance for your help!

About

Get restock notifications right in your desktop OS when rpilocator.com sees a Raspberry Pi restock

Resources

Stars

Watchers

Forks

Releases

Packages

Used by

Contributors

Languages