Commit Graph

1114 Commits

Author SHA1 Message Date
dadaloop82 f46b12e3ad feat: recipe favorites (#124), portion rescaler (#123), financial waste report (#117), macronutrient panel (#118)
- #124: star toggle on recipe view + favorites shown first in archive with gold border
- #123: +/- persons buttons on recipe to scale ingredient quantities
- #117: wasted value in EUR displayed in monthly stats section
- #118: macronutrient breakdown panel (P/C/F/fiber bars) with 4th insight rotation phase
- DB: is_favorite column on recipes, nutriments_json on products (auto-migrated)
- OFF API: nutriments fields fetched and stored per product
- Translations: it/en/de/fr/es updated with new keys
2026-05-26 18:09:32 +00:00
github-actions[bot] a932d3de11 chore: auto-merge develop → main
Triggered by: 6120fad chore: update CHANGELOG for v1.7.26
2026-05-26 17:31:48 +00:00
dadaloop82 6120fad40b chore: update CHANGELOG for v1.7.26 2026-05-26 17:30:17 +00:00
github-actions[bot] 8ac6fec5a2 chore: auto-merge develop → main
Triggered by: 4f68925 fix: insight banner rotation 30s → 60s (1 minute per panel)
2026-05-26 17:29:50 +00:00
github-actions[bot] fe7587e9e4 chore: auto-merge develop → main
Triggered by: f4ea9e7 fix: banner rotation (30s interval, skip empty phases) + normalize OFF categories
2026-05-26 17:28:44 +00:00
dadaloop82 4f68925a7c fix: insight banner rotation 30s → 60s (1 minute per panel) 2026-05-26 17:28:22 +00:00
dadaloop82 f4ea9e74e6 fix: banner rotation (30s interval, skip empty phases) + normalize OFF categories
- _startInsightAlternation: 3_600_000ms → 30_000ms so rotation is actually
  visible without waiting an hour
- _applyInsightPhase: smart phase-skip instead of always falling back to waste;
  if current phase has no content, advance to the next non-empty phase
- PHP: add _normalizeCat() mapping OpenFoodFacts slug format ('en:dairies',
  'en:plant-based-foods-and-beverages', …) to Italian app categories; also
  re-aggregates counts after normalization so 'en:dairies' + 'en:milk' both
  count toward 'latticini' correctly
- JS _renderMonthlyStatsSection: guard t() fallback — if t() returns the key
  itself (not found), display a cleaned-up slug instead of the raw key
2026-05-26 17:26:57 +00:00
github-actions[bot] 8f217fd166 chore: auto-merge develop → main
Triggered by: b985247 feat: monthly stats panel in rotating insight banner (closes #100)
2026-05-26 17:21:45 +00:00
dadaloop82 b985247b95 feat: monthly stats panel in rotating insight banner (closes #100)
- Add PHP action 'monthly_stats' + getMonthlyStats() function:
  items consumed/added/wasted this month, trend vs prev month,
  top 5 categories and top 3 products by transaction count
- Expand insight rotation from 2 → 3 phases (waste → nutrition → monthly)
- Add _renderMonthlyStatsSection() following nutrition section styling:
  large indigo number, trend arrow with %, horizontal category bars
  animated on show, badges for added/wasted/top-product
- Add ms-* CSS classes (bar chart layout matching nutr-* design)
- Add stats_monthly translations in it/en/de/fr/es (10 keys each)
2026-05-26 17:19:54 +00:00
github-actions[bot] efbed479df chore: auto-merge develop → main
Triggered by: 695c23f feat: smart shopping extended horizon for staple items (closes #98)
2026-05-26 17:10:43 +00:00
dadaloop82 695c23fc21 feat: smart shopping extended horizon for staple items (closes #98)
Products used ≥ 4x/month (daily staples: latte, pane, uova) now appear in
the smart shopping list when stock will deplete within 28 days (instead of 14).
Products used ≥ 2x/month (weekly staples: yogurt, frutta, carne) appear
within 21 days. The existing ≥1.5x/month rule at 14 days is unchanged.

No manual pin or UI needed: frequency is detected automatically from
transaction history. justRestocked guard prevents noise for freshly
bought items.
2026-05-26 17:09:04 +00:00
github-actions[bot] 7a34406b07 chore: auto-merge develop → main
Triggered by: 50660f6 fix: TTS test ask user if heard + PHP 8 end() ref bug + DB migration guard for fresh volumes
2026-05-26 15:01:40 +00:00
dadaloop82 50660f634f fix: TTS test ask user if heard + PHP 8 end() ref bug + DB migration guard for fresh volumes
- app.js: TTS kiosk timeout 4s → 10s; fires interactive 'Hai sentito?' YES/NO
  prompt instead of showing error (TTS can take 6-8s; UtteranceProgressListener
  may not fire on all firmware); YES → success, NO → troubleshooting steps
- translations: add heard_question/heard_yes/heard_no/test_ok_kiosk/test_fail_steps
  to all 5 languages (it/en/de/fr/es) under settings.tts
- api/index.php: fix end() PHP 8.0+ reference error in _offFetchProduct()
  (categories_hierarchy stored in temp var before calling end())  (fixes #130)
- api/database.php: migrateDB() now checks sqlite_master for 'products' table;
  if missing, calls initializeDB() and returns — no ALTER on nonexistent table
  (fixes #133, covers #131)
- api/index.php: health_check db_row_count query guarded against missing
  inventory table (fixes #131)
2026-05-26 14:59:17 +00:00
github-actions[bot] fb06b42107 chore: auto-merge develop → main
Triggered by: c16067d fix(kiosk): scale retry restores nav buttons + settings link to webapp
2026-05-26 14:44:57 +00:00
dadaloop82 c16067d9e5 fix(kiosk): scale retry restores nav buttons + settings link to webapp
SetupActivity:
- btnTestRetry click handler: add step3NextButtons.visibility = VISIBLE
  so the Indietro/Avanti buttons reappear after pressing No-retry
  (previously they stayed hidden → user was stuck with no way to go back)
- onDisconnected(): always re-enable btnTestRetry so user is never stuck
  when scale drops unexpectedly before a weight reading arrives

SettingsActivity / activity_settings.xml:
- Add 'IMPOSTAZIONI AVANZATE' section explaining that HA, Gemini AI,
- Add '← Torna all'app per le impostazioni avanzate' button (finish())
2026-05-26 14:42:27 +00:00
github-actions[bot] 605d8590f6 chore: auto-merge develop → main
Triggered by: 149cff3 fix(kiosk): force STREAM_MUSIC for TTS + JS feedback callbacks
2026-05-26 14:04:23 +00:00
dadaloop82 149cff3ca5 fix(kiosk): force STREAM_MUSIC for TTS + JS feedback callbacks
Android TTS was silently failing because engine.speak() used the default
audio stream, which may be muted while the media stream is not.

Changes:
- KioskActivity: speak() now passes Bundle with KEY_PARAM_STREAM=STREAM_MUSIC
  so TTS plays on the same channel as beep/media audio
- KioskActivity: add UtteranceProgressListener that calls window._kioskTtsDone()
  or window._kioskTtsError(uid, code) back into the WebView on completion/failure
- app.js testTTS(): kiosk path now shows real result from Android callbacks
  (success/error) with a 4s fallback timeout showing actionable troubleshooting hints
2026-05-26 14:02:31 +00:00
github-actions[bot] ec7d172ed9 chore: auto-merge develop → main
Triggered by: 0479e34 ci: retry after GitHub CDN outage
2026-05-26 13:53:56 +00:00
dadaloop82 0479e34c7f ci: retry after GitHub CDN outage 2026-05-26 13:52:15 +00:00
dadaloop82 730efe4d87 ci: force Node.js 24 for JS actions (deadline June 2, 2026)
Add FORCE_JAVASCRIPT_ACTIONS_TO_NODE24=true env var to ci.yml,
security.yml and build-kiosk.yml to prevent action failures when
GitHub removes Node 20 runner support on 2026-06-02.

Also re-triggers CI to bypass transient 403 infrastructure failure
that hit the previous run (GitHub CDN outage).
2026-05-26 12:31:37 +00:00
dadaloop82 be3dceeebb feat: add separate sound beep test button + always show move modal on open
- Add testSound() function: plays AudioContext beep independently of TTS
- Add '🔔 Esegui Test Suono' button in TTS settings (above voice test btn)
- Add translations: settings.tts.test_sound_btn (it/en/de)
- Remove hasOtherLocs guard in showMoveAfterUseModal: always show
  location-choice modal when opening a package, regardless of whether
  the product already exists in other locations (e.g. peas only in pantry
  → user can now choose to move opened portion to fridge)
2026-05-26 12:17:18 +00:00
dadaloop82 875250626d fix: prefer offline voices in TTS; add beep + real diagnostics to test
_speakBrowser: voice fallback now prefers localService=true (offline)
voices over cloud voices. On Android Chrome, cloud voices fail silently
when no internet. New priority: local Italian → any Italian → local
any-lang → first available → lang-only.

testTTS (browser engine):
- Plays _playCookingTimerSound('done') beep FIRST (AudioContext, always
  works) so user can confirm audio hardware/volume is working
- Checks if only cloud voices exist → shows actionable error
- Builds utterance with onerror → shows error code on failure
- Adds onstart → shows actual voice name/lang/online status on success
- 2s watchdog: if onstart never fires → 'nessuna risposta' warning
- Shows '🔊 Beep + TTS in corso...' during the test
2026-05-26 12:11:52 +00:00
dadaloop82 245d007e29 fix: Chrome speechSynthesis paused-state bug + better TTS diagnostics
_speakBrowser: Chrome sets speechSynthesis.paused=true after tab is
backgrounded/minimized. Calling cancel() does NOT clear this state.
Adding resume() before speak() inside the setTimeout fixes silent
failure when user returns to the tab (e.g. switch app → back to browser).

testTTS: add diagnostic messages for:
- Android kiosk: check isTtsReady() and show actionable error if
  the native TTS engine hasn't initialized yet
- Web browser: check getVoices().length before speaking; if empty,
  show error asking user to install a voice pack in OS settings
  (instead of always showing ' Riproduzione in corso' even when silent)
2026-05-26 12:04:31 +00:00
github-actions[bot] 63a9f70f86 chore: auto-merge develop → main
Triggered by: 1a6e0c8 fix: robust browser TTS voice selection and Chrome cancel+speak workaround
2026-05-25 17:56:33 +00:00
dadaloop82 1a6e0c87ce fix: robust browser TTS voice selection and Chrome cancel+speak workaround
_speakBrowser() was silently failing in two scenarios:

1. Chrome cancel+speak bug: calling speechSynthesis.speak() immediately
   after cancel() is silently dropped in Chrome. Fixed by adding a 50ms
   setTimeout between cancel() and speak().

2. No voice fallback: when tts_voice preference is empty (never saved)
   and the browser has no default 'it-IT' voice, speech fails silently.
   Now tries: preferred by name → first Italian voice → first any voice
   → lang-only as last resort.

3. Async voice loading: Chrome/Android load voices asynchronously.
   When getVoices() returns empty, now waits for onvoiceschanged (with
   a 500ms safety timeout) before speaking.
2026-05-25 17:55:04 +00:00
github-actions[bot] 73f43cb296 chore: auto-merge develop → main
Triggered by: baed815 fix: translate CATEGORY_LABELS and #pf-category after i18n load
2026-05-25 17:43:55 +00:00
dadaloop82 baed815a48 fix: translate CATEGORY_LABELS and #pf-category after i18n load
CATEGORY_LABELS was built at parse time before translations were
available, causing raw keys like 'categories.verdura' to appear
in all category labels, dropdowns and inventory filters.

_applyI18nToLabels() now also:
- Rebuilds each CATEGORY_LABELS entry using the loaded i18n strings
  and the corresponding CATEGORY_ICONS icon prefix
- Regenerates the static #pf-category <select> options so the
  product-add form also shows translated category names
2026-05-25 17:42:10 +00:00
github-actions[bot] 8aa934f5ca chore: auto-merge develop → main
Triggered by: 83b5eb3 fix: browser TTS ignored when HA TTS configured; wrong ha_hint i18n key
2026-05-25 10:38:53 +00:00
dadaloop82 83b5eb3063 fix: browser TTS ignored when HA TTS configured; wrong ha_hint i18n key
- speakCookingStep: respect tts_engine='browser' explicitly; if user
  chose browser engine, always use _speakBrowser regardless of HA.
  Also add per-engine try/catch so HA or server TTS failures fall back
  to browser TTS instead of silently doing nothing.
- index.html: fix data-i18n='settings.tts.ha_hint' → 'settings.ha.ha_hint'
  (key lived in settings.ha not settings.tts)
2026-05-25 10:37:17 +00:00
github-actions[bot] 59c6f9d76c chore: auto-merge develop → main
Triggered by: bac9485 fix: hide ingredients panel in cooking mode
2026-05-25 10:21:51 +00:00
dadaloop82 bac9485e4e fix: hide ingredients panel in cooking mode
Ingredients are already shown (with use buttons) in the recipe
result screen. In cooking mode only steps should appear.
2026-05-25 10:20:17 +00:00
github-actions[bot] 11178af001 chore: auto-merge develop → main
Triggered by: 4e4a736 feat: ask replace vs save-to-archive on regenerate recipe
2026-05-25 10:13:43 +00:00
dadaloop82 4e4a736dba feat: ask replace vs save-to-archive on regenerate recipe
When user clicks 'Generate another', show a choice:
- Replace (discard current, generate new) — former behavior
- Save to archive & generate new — saves current recipe first

All 5 languages (it/en/de/fr/es) with regen_choice_title,
regen_replace, regen_save_new keys.
2026-05-25 10:11:56 +00:00
dadaloop82 52afdd6bfa fix(recipes): steps shown as raw JSON when AI uses instruction/appliance_function objects
- _stepStr: parse JSON-string steps; handle s.instruction key (backward-compat with already-saved recipes)
- _stepAppliance: new helper to extract appliance_function hint; returns null for 'Nessuno'/'None'
- renderRecipe steps list: shows appliance badge inline after step text when present
- CSS: .recipe-step-appliance badge (green chip, dark-mode variant)
- Prompt (both generateRecipe + generateRecipeStream): rule 9/10 explicitly forbids step objects;
  appliance info must be embedded in the step text string directly
2026-05-25 10:01:10 +00:00
github-actions[bot] 3d27433eb3 chore: auto-merge develop → main
Triggered by: eddb622 feat(offline): full offline mode — cache sync, write queue, startup recovery
v1.7.25
2026-05-25 09:27:09 +00:00
dadaloop82 eddb622c85 feat(offline): full offline mode — cache sync, write queue, startup recovery
- Full-screen network error overlay (z-index 300000, above screensaver)
- 'Continue offline' button after 3s, auto-enter after 8s
- Inventory + settings synced to localStorage at startup (during health check)
- inventory_summary and stats computed from local cache while offline
- Write queue (add/use/update/delete): optimistic UI + sync on reconnect
- Pending ops survive page refresh — detected and re-synced at next startup
- Buffered remoteLog/reportError flushed to server (GitHub issues) on restore
- AI/network sections hidden in offline mode (CSS body.offline-mode)
- Banner: pulsing dot while loading cache, item count when ready
- Broken external images replaced with grey SVG placeholder
- Fix: opened items marked is_edible:true offline (was flooding banner)
- Fix: _semverGt() prevents update badge for older GitHub releases
- Bump version to v1.7.25
2026-05-25 09:05:19 +00:00
github-actions[bot] 95c20adbbd chore: auto-merge develop → main
Triggered by: 6fa2e4d docs: HA integration section first in README, with HACS buttons and full feature table
2026-05-23 20:43:02 +00:00
dadaloop82 6fa2e4d830 docs: HA integration section first in README, with HACS buttons and full feature table
- Replaces the old 'New' callout with a proper dedicated section at the top of Features
- Shows all 16 sensors, 6 binary sensors, 5 buttons, todo, calendar, text, 6 services
- HACS and config_flow_start my.home-assistant.io badge buttons

Also: fix dark mode not persisting — _setThemeMode now saves immediately to server .env
2026-05-23 20:41:29 +00:00
github-actions[bot] 6ff1dfe0cc chore: auto-merge develop → main
Triggered by: 43e0ac9 feat(ha): v1.1.0 backend — haCalendar, haSuggestRecipe, haRefreshPrices, haClearExpired + enriched haInventorySensor
2026-05-23 20:24:46 +00:00
dadaloop82 43e0ac9da3 feat(ha): v1.1.0 backend — haCalendar, haSuggestRecipe, haRefreshPrices, haClearExpired + enriched haInventorySensor
New endpoints:
- ha_calendar: returns all expiry dates as calendar events
- ha_suggest_recipe: AI recipe suggestion from expiring items (Gemini)
- ha_refresh_prices: recompute shopping total from price cache only
- ha_clear_expired: delete zero-stock expired rows

haInventorySensor now returns:
- items_dispensa, items_frigo, items_freezer, items_other
- low_stock_items, zero_stock_items
- ai_calls_month, last_backup_at
- days_to_next_expiry, next_expiry_name, next_expiry_date
- bring_connected, shopping_total, price_tracking_enabled, price_currency
2026-05-23 20:22:51 +00:00
github-actions[bot] 1ce32cb5f0 chore: auto-merge develop → main
Triggered by: d75cde7 feat(ha): add expiring_today, next_expiry_name/date, expires_today flag
2026-05-23 20:09:32 +00:00
dadaloop82 d75cde7eb6 feat(ha): add expiring_today, next_expiry_name/date, expires_today flag 2026-05-23 20:07:54 +00:00
github-actions[bot] 43fe1c7bb5 chore: auto-merge develop → main
Triggered by: b2c87ae feat(ha): enrich ha_sensor with opened_items, shopping_total, price_tracking, expiring_3d
2026-05-23 20:00:36 +00:00
dadaloop82 b2c87ae343 feat(ha): enrich ha_sensor with opened_items, shopping_total, price_tracking, expiring_3d 2026-05-23 19:58:49 +00:00
github-actions[bot] fbdae35516 chore: auto-merge develop → main
Triggered by: d9ebc51 fix: ha_sensor JOIN products for name/unit columns (was HTTP 500)
2026-05-23 14:39:37 +00:00
dadaloop82 d9ebc51e71 fix: ha_sensor JOIN products for name/unit columns (was HTTP 500) 2026-05-23 14:38:01 +00:00
github-actions[bot] 56ca58bc18 chore: auto-merge develop → main
Triggered by: b2e0f6d feat: add ha_info, ha_shopping_items endpoints and avahi mDNS service file for HACS integration
2026-05-23 13:25:19 +00:00
dadaloop82 b2e0f6d683 feat: add ha_info, ha_shopping_items endpoints and avahi mDNS service file for HACS integration
- api/index.php: new haGetInfo() endpoint (unique_id, version, instance, items count)
- api/index.php: new haGetShoppingItems() endpoint (Bring! + internal shopping list)
- api/index.php: haInventorySensor() now accepts ?expiry_days=N query param
- api/cron_smart_shopping.php: auto-register avahi mDNS service if avahi-daemon present
- docker/avahi-evershelf.xml: Zeroconf _evershelf._tcp service declaration
- .env.example: add INSTANCE_NAME variable (used by HA integration for device label)
2026-05-23 13:23:28 +00:00
github-actions[bot] ddb9bd9f75 chore: auto-merge develop → main
Triggered by: 965a672 feat: full Home Assistant integration
2026-05-23 12:30:02 +00:00
dadaloop82 965a672abe feat: full Home Assistant integration
- PHP: _fireHaWebhook(), _sendHaNotify(), haInventorySensor(), haTestConnection()
- PHP: ha_sensor + ha_test routing actions
- PHP: getServerSettings() exposes ha_token (consistent with tts_token)
- PHP: saveSettings() handles all HA_* env keys (url, token, tts_entity, webhook_id, events, notify_service, expiry_days)
- PHP: bringAddItems(), shoppingAdd(), updateInventory() fire shopping_add / stock_update webhooks
- Cron: daily HA expiry/expired webhook + push notify with flag-file guard
- HTML: 🏠 Settings tab button + full HA panel (connection, TTS, webhook, notify, sensor cards)
- JS: serverKeys + loadSettingsUI extended with HA fields
- JS: _applyHaSettingsUI(), _loadHaTab(), _renderHaSensorYaml()
- JS: onHaEnabledChange(), testHaConnection(), applyHaTtsPreset()
- JS: saveHaSettings(), copyHaSensorYaml(), showHaWebhookHelp()
- JS: _buildHaTtsRequest() for HA media_player TTS
- JS: speakCookingStep() now supports HA TTS as first-priority path
- JS: onTtsEngineChange() fixed to show server section for both 'server' and 'custom'
- Translations: settings.ha.* (52 keys) in all 5 languages (it/en/de/fr/es)
- .env.example: HA_ENABLED/URL/TOKEN/TTS_ENTITY/WEBHOOK_ID/EVENTS/NOTIFY_SERVICE/EXPIRY_DAYS
- docs/wiki/Home-Assistant.md: new wiki page (REST sensors, webhooks, TTS, push notify, troubleshooting)
- README: HA integration highlighted as first feature block
2026-05-23 12:28:09 +00:00