Skip to content

Windows app for tracking medical cannabis usage and stock with a built-in Medicann scraper, mix calculator, and Home Assistant notifications.

Notifications You must be signed in to change notification settings

Anzymanz/FlowerTrack

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

705 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FlowerTrack

FlowerTrack is a Windows desktop app for tracking medical cannabis usage and stock, with an integrated Medicann scraper and local Flower Browser. It combines a dosage tracker, flower library, API-first catalog capture, and automated price/stock change detection with optional Home Assistant and Windows notifications.

Download (Windows)

Download the latest FlowerTrack.exe from Releases.

Features

  • Track flower stock, THC/CBD potency, remaining grams, and daily targets.
  • Log doses by route of administration with per-day totals.
  • Flower Library and Mix Calculator tools.
  • Medicann scraper with API pagination and change detection (new/removed items, price/stock changes, restocks, out-of-stock).
  • API auth bootstrap flow (including manual login bootstrap on first run when credentials are missing).
  • Home Assistant webhook notifications and optional Windows desktop notifications.
  • Flower Browser served at fixed endpoint (/flowerbrowser) with filters, badges, favorites, basket, and image previews.
  • Change history viewer in both scraper UI and Flower Browser.
  • Theme customization with colour pickers (including tracker thresholds and dark/light palette overrides).
  • Optional network modes (-host / -client) to share tracker/library data and the Flower Browser over LAN (access-key protected, LAN-only by default, optional rate limiting).
  • Optional console mode (-console) for live stdout/stderr output from the built exe.
  • Minimize/close-to-tray support (when enabled in settings).

Screenshots

Tracker dashboard

Shows usage, stock, and daily targets in a single view.

Usage stats

Shows usage history and trends over time.

Flower library

Stores strains, notes, and metadata.

Scraper window

Shows auto-scraper controls, progress, and log output.

Flower Browser

Local webpage with filters, badges, and change highlights.

Flower Browser favorites

Favorites list for quick access.

Flower Browser basket

Basket view for comparing items.

Mix calculator

Calculator for blend ratios.

Stock mix calculator

Calculator view for combining stock entries.

The Flower Browser (webpage)

The scraper generates HTML that is served from a fixed endpoint:

http://127.0.0.1:<port>/flowerbrowser (default port: 8765)

In -client mode, the app opens the host endpoint instead:

http://<host-ip>:<browser-port>/flowerbrowser

It is designed for fast scanning and filtering of the live product list.

Key features:

  • Search, filter, and sort by brand, strain, type, stock, THC, and CBD.
  • Dedicated irradiation filters (β and γ) for quick beta/gamma product filtering.
  • Category filters for flower, oil, vape, and pastille products.
  • Visual badges for new/removed items, price movement, out‑of‑stock, and restock highlights.
  • Per‑gram pricing and THC/CBD normalization.
  • Flags for origin country and irradiation type (where available).
  • Brand images with click‑to‑enlarge previews.
  • Favorites and basket lists stored locally in the page.
  • Live "new page available" banner when a newer export is detected.
  • Embedded change history modal with readable detail formatting.

Scraper behavior

  • Uses API-first capture and paginates through the full product list.
  • Validates pagination completeness and skips parse/apply on interrupted/partial capture.
  • Uses cached auth tokens and refreshes via Playwright bootstrap when required.
  • Supports manual visible-browser bootstrap when credentials are incomplete on first run.
  • Sends notifications only when changes are detected (per notification toggles).
  • In -client mode, scraper controls are disabled and data is read from host sync.

Run modes and flags

  • FlowerTrack.exe (or py .\flowertracker.py): standalone mode.
  • FlowerTrack.exe -host: host mode (runs local tracker + data sync API + browser endpoint for clients).
  • FlowerTrack.exe -client: client mode (reads tracker/library data from host, disables local scraper controls).
  • FlowerTrack.exe -console: opens a console window and mirrors runtime logs to stdout/stderr.
  • FlowerTrack.exe --diagnostics: prints diagnostic JSON and exits.

Home Assistant setup

  1. In Home Assistant, create a webhook automation (Settings → Automations → Create → Webhook).
  2. Set the webhook ID (e.g., flowertrack) and save the automation.
  3. Copy the webhook URL from the automation (it looks like https://YOUR_HA/api/webhook/flowertrack).
  4. In FlowerTrack → Scraper settings, paste the webhook URL into Home Assistant webhook URL.
  5. Optional: set a long‑lived access token in Home Assistant token if your HA instance requires it.
  6. Save settings and use Send test notification to verify.
  • Payload includes new/removed items, price changes, and stock changes.
  • Quiet hours and summary/full detail are configurable.

Example Home Assistant automation

- id: flowertrack_webhook
  alias: FlowerTrack Webhook
  mode: parallel
  trigger:
    - platform: webhook
      webhook_id: flowertrack

  variables:
    new_msg: >
      {% if trigger.json.new_item_summaries %}
        New: {{ trigger.json.new_item_summaries | join(', ') }}
      {% elif trigger.json.new_items %}
        New: {{ trigger.json.new_items | join(', ') }}
      {% else %}{{ '' }}{% endif %}
    removed_msg: >
      {% if trigger.json.removed_item_summaries %}
        Removed: {{ trigger.json.removed_item_summaries | join(', ') }}
      {% else %}{{ '' }}{% endif %}
    price_msg: >
      {% if trigger.json.price_change_summaries %}
        Price: {{ trigger.json.price_change_summaries | join('; ') }}
      {% else %}{{ '' }}{% endif %}
    stock_msg: >
      {% if trigger.json.stock_change_summaries %}
        Stock: {{ trigger.json.stock_change_summaries | join('; ') }}
      {% else %}{{ '' }}{% endif %}
    restock_msg: >
      {% if trigger.json.restock_change_summaries %}
        Restock: {{ trigger.json.restock_change_summaries | join('; ') }}
      {% else %}{{ '' }}{% endif %}
    parts: >
      {{ [new_msg, removed_msg, price_msg, stock_msg, restock_msg]
         | reject('equalto','')
         | reject('equalto', None)
         | list }}
    combined: >
      {% if parts|length > 0 %}
        {{ parts | join(' | ') }}
      {% else %}
        Payload: {{ trigger.json | tojson }}
      {% endif %}

  action:
    - service: notify.mobile_app_pixel_9_pro_xl
      data:
        title: "FlowerTrack Update"
        message: "{{ combined }}"

Desktop notifications

  • Enable "Send Windows desktop notifications" in scraper settings.
  • Uses win10toast-click when available (falls back to win10toast).

Configuration and data

All user data and configs are stored under:

%APPDATA%\FlowerTrack

Key files:

  • flowertrack_config.json (unified tracker + scraper settings)
  • data\tracker_data.json and data\library_data.json
  • Exports\ (latest export HTML + changes_latest.json)
  • logs\changes.ndjson (change history)
  • dumps\ (optional API dumps when enabled)

Credentials and tokens are stored encrypted (DPAPI on Windows).

Requirements

  • Windows 10/11
  • Python 3.12 (dev only)
  • Playwright browsers (used for authenticated scraping; auto-installed on first run or via playwright install)
  • certifi (dev/runtime dependency for HTTPS validation on fresh PCs)

Quick start (development)

py .\flowertracker.py

Quick start (Windows exe)

  1. Download the latest FlowerTrack.exe from Releases.
  2. Run FlowerTrack.exe (first run may take a little longer).

Build (single exe)

Use the one-liner in buildline.txt, or:

Remove-Item -Recurse -Force dist, build, FlowerTrack.spec -ErrorAction SilentlyContinue; $env:PYTHONWARNINGS="ignore"; pyinstaller --onefile --windowed --icon assets/icon.ico --add-data "assets;assets" --add-data "flowerlibrary.py;." --add-data "mixcalc.py;." --add-data "mix_utils.py;." --splash assets/BannerRound.png --exclude-module setuptools.msvc --name FlowerTrack flowertracker.py

Tests

py -m pytest

Troubleshooting

  • If Playwright browsers are missing, run:
    playwright install
  • If the scraper logs "No products parsed", increase wait time or retries.
  • If you see SSL/certificate errors on a fresh PC (CERTIFICATE_VERIFY_FAILED), install/update certifi and restart:
    py -m pip install -U certifi
    The app uses certifi for API/HA HTTPS validation; missing roots on Windows can cause fetch failures.
  • If scraper settings look blank or defaults are missing, delete %APPDATA%\FlowerTrack\flowertrack_config.json and relaunch to re-seed defaults.
  • Use the console log in-app for detailed scrape output.
  • In -client mode:
    • Confirm host IP/ports and Access key in settings (host and client must match).
    • Ensure the host is reachable on the LAN (host blocks public/global client IPs by default).
    • If you see HTTP 429, raise the host rate limit in settings (Data settings, host mode) or reduce client polling frequency.

Repository layout

  • flowertracker.py entry point
  • ui_*.py UI modules
  • capture.py scraper worker
  • parser.py API payload parser and dedupe logic
  • exports.py + export_template.py Flower Browser HTML generation
  • export_server.py local HTTP server for /flowerbrowser and live export events
  • config.py config persistence and migrations
  • tests/ unit tests

About

Windows app for tracking medical cannabis usage and stock with a built-in Medicann scraper, mix calculator, and Home Assistant notifications.

Topics

Resources

Contributing

Stars

Watchers

Forks

Languages