The Park Slope Food Co-op is a member-run grocery store in Brooklyn, NY where every member is required to work a shift roughly once a month in exchange for the right to shop. Open shifts that get released back to the pool (when someone cancels, swaps, or a new cycle opens) are claimed on a first-come, first-served basis and tend to disappear within seconds. This script logs into the members site, watches the shift calendar across the next several weeks, and auto-claims an open shift the moment one appears, using a configurable priority list so you get the time slot and role you actually want.
- Multi-week monitoring: Simultaneously monitors shifts across 6 weeks
- Smart priority system: Claims shifts based on your preferred times and roles
- Auto-claim with limits: Respects co-op shift limits (default: 2 shifts max)
- Already-claimed detection: Skips shifts you've already claimed (green checkmark)
- Retry mechanism: Attempts to reclaim shifts if they become available again
- Multi-channel notifications:
- Windows sound alerts
- Pushbullet notifications
- Alexa voice announcements via Home Assistant
- Python 3.x
- Chrome browser
- Chrome WebDriver
- Home Assistant instance (optional, for notifications)
- Pushbullet account (optional)
- Alexa devices with Home Assistant integration (optional)
- Clone this repository:
git clone [your-repo-url]
cd auto_refresh- Install required packages:
pip install selenium requests- Download Chrome WebDriver:
- Download from ChromeDriver
- You'll point the script at these paths via environment variables (see Setup below)
All secrets and machine-specific paths are read from environment variables. Nothing is hardcoded in the script. Copy .env.example to .env (or export the variables in your shell however you prefer) and fill in real values. The script does not load .env automatically; either export the variables in your shell session before running, or use a tool of your choice to load them.
The following environment variables are required (the script will raise KeyError on startup if any are missing):
| Variable | Description |
|---|---|
CHROME_BINARY |
Absolute path to your Chrome (or Chrome for Testing) executable. |
CHROME_USER_DATA_DIR |
Absolute path to the Chrome user-data directory containing the profile you're logged into the co-op with. |
CHROMEDRIVER_PATH |
Absolute path to the matching chromedriver executable. |
YOUR_INITIALS |
Your member initials, as entered on the co-op claim form (e.g. PD). |
HA_URL |
Base URL of your Home Assistant instance (e.g. http://192.168.1.10:8123). |
HA_TOKEN |
A Home Assistant long-lived access token. See Home Assistant docs for how to create one. |
HA_NOTIFY_SERVICE |
The notify service to use (e.g. notify.pushbullet). |
See .env.example in the repo root for a template with placeholder values.
If you don't use Home Assistant, set ENABLE_HA_NOTIFICATIONS = False near the top of auto_claim.py. The HA env vars must still be defined (use any placeholder values).
Edit the configuration section in auto_claim.py:
AUTO_CLAIM = True # Set to False for notification-only mode
CREDIT_TO_SELF = True # True = credit yourself, False = credit housemate
MAX_SHIFTS = 2 # Maximum shifts to claim (co-op limit)
WEEKS_TO_MONITOR = 6 # Number of weeks to monitor (1-6)YOUR_INITIALS is set via the environment variable of the same name (see Setup).
Define your preferred shifts in order of priority:
SHIFT_PRIORITIES = [
{"time": "10:30am", "role": None}, # Any 10:30am shift
{"time": "1:00pm", "role": None}, # Any 1:00pm shift
{"time": None, "role": "Cart Return"}, # Any Cart Return shift
{"time": None, "role": None}, # Any other shift
]Chrome and ChromeDriver paths are set via the CHROME_BINARY, CHROME_USER_DATA_DIR, and CHROMEDRIVER_PATH environment variables (see the Setup section above).
HA_URL, HA_TOKEN, and HA_NOTIFY_SERVICE are configured via environment variables (see the Setup section above). To toggle notifications on or off, edit the ENABLE_HA_NOTIFICATIONS flag near the top of auto_claim.py.
To get a Home Assistant token:
- Go to your HA profile (click username in bottom left)
- Scroll to "Long-Lived Access Tokens"
- Create a new token and copy it into your
.env
- Run the script:
python auto_claim.py-
If not already logged in, the script will wait for you to log into the food co-op website
-
The script will:
- Open tabs for each week you're monitoring
- Check for available shifts every 3 seconds
- Notify you when shifts become available
- Auto-claim shifts matching your priorities (if enabled)
- Send notifications to all configured channels
-
Press
Ctrl+Cto stop monitoring
- Shift Detection: Searches for
<a class="shift">elements on each page - Claimed Detection: Skips shifts with
my_shiftclass (your claimed shifts with ✅) - Priority Matching: Claims shifts in order of your defined priorities
- Failure Handling: Retries failed claims up to 3 times
- Notification System: Sends alerts via multiple channels when shifts are claimed
- Verify the paths in the configuration match your installation
- Ensure Chrome and ChromeDriver versions are compatible
- Check your Home Assistant token is valid
- Verify Home Assistant is accessible at the configured URL
- Ensure Pushbullet and Alexa integrations are set up in HA
- The script now detects the green checkmark (✅) on claimed shifts
- If issues persist, check that the
my_shiftclass detection is working
- The script tracks failed attempts and will retry up to 3 times
- Shifts are removed from the "seen" list after release
- Respects co-op shift limits
- Won't claim more than MAX_SHIFTS
- Handles alerts and confirmations automatically
- Graceful error handling with retry logic
- Network failure resilience for notifications
This tool is for personal use. Please respect your co-op's policies regarding shift claiming and automation. The authors are not responsible for any issues arising from the use of this script.