Add the Fresh Harvest dashboard view as an example

Ships the tab that is running on ha-box: a delivery countdown, order tiles,
box contents rendered from the item attributes, and the still-open order.
This commit is contained in:
flan
2026-08-03 19:02:11 +00:00
parent cd20802127
commit a97f0aec6a
3 changed files with 102 additions and 0 deletions
+2
View File
@@ -25,3 +25,5 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
parsing, and year rollover on undated cart tabs.
- English translations under `translations/en.json`, which is where custom
integrations read entity and config-flow strings from.
- Example dashboard view under `examples/dashboard-view.yaml`: a three-section
tab with a delivery countdown, order tiles, and the full box contents.
+8
View File
@@ -47,6 +47,14 @@ Two traps are worth recording, since neither is guessable from the outside:
"skipped" reports the wrong delivery as cancelled. The reliable signal for
"can still be changed" is a non-empty `.cart-customize-wrapper`.
## Dashboard
[examples/dashboard-view.yaml](examples/dashboard-view.yaml) is a ready-made tab
for these sensors — a countdown heading ("Arriving tomorrow"), tiles for the
date, total and item count, the full box contents rendered from the attributes,
and the still-changeable order with a link back to the portal. Paste it under
`views:` in the raw configuration editor.
## Installation
Copy `custom_components/freshharvest/` into your Home Assistant
+92
View File
@@ -0,0 +1,92 @@
# Fresh Harvest dashboard view.
#
# This is the tab shipped alongside the integration: three sections covering the
# next delivery, what is in the box, and the order that can still be changed.
#
# To use it, open your dashboard, choose "Edit dashboard" -> "Raw configuration
# editor", and paste this under `views:`. It only needs the five sensors the
# integration creates.
type: sections
max_columns: 4
icon: mdi:basket
path: fresh-harvest
sections:
- type: grid
cards:
- type: heading
heading: Next Delivery
heading_style: title
icon: mdi:truck-delivery
- type: markdown
content: |-
{%- set d = states('sensor.fresh_harvest_next_delivery') -%}
{%- set box = state_attr('sensor.fresh_harvest_next_delivery_items', 'box') -%}
{%- if d not in ['unknown', 'unavailable', 'none'] -%}
{%- set days = (d | as_datetime).date() - now().date() -%}
{%- set n = days.days -%}
## {% if n < 0 %}Delivered{% elif n == 0 %}Arriving today{% elif n == 1 %}Arriving tomorrow{% else %}Arriving in {{ n }} days{% endif %}
{{ (d | as_datetime).strftime('%A, %B %-d') }}{% if box %} · {{ box }}{% endif %}
{%- else -%}
## No delivery scheduled
{%- endif -%}
- type: tile
entity: sensor.fresh_harvest_next_delivery
name: Arriving
icon: mdi:calendar-clock
color: green
- type: tile
entity: sensor.fresh_harvest_next_delivery_total
name: Order total
icon: mdi:cash-multiple
color: teal
- type: tile
entity: sensor.fresh_harvest_next_delivery_items
name: Items
icon: mdi:basket-check
color: light-green
- type: grid
cards:
- type: heading
heading: What's Coming
heading_style: title
icon: mdi:carrot
- type: markdown
content: |-
{%- set produce = state_attr('sensor.fresh_harvest_next_delivery_items', 'produce') or [] -%}
{%- set addons = state_attr('sensor.fresh_harvest_next_delivery_items', 'add_ons') or [] -%}
{%- if produce -%}
**In the box**
{% for i in produce %}
- {{ i }}
{%- endfor %}
{%- else -%}
_Box contents not assigned yet._
{%- endif %}
{% if addons %}
**Add-ons**
{% for a in addons %}
- {{ a }}
{%- endfor %}
{%- endif -%}
- type: grid
cards:
- type: heading
heading: Still Open
heading_style: title
icon: mdi:cart-arrow-right
- type: tile
entity: sensor.fresh_harvest_open_order_delivery
name: Delivery
icon: mdi:calendar-arrow-right
color: amber
- type: tile
entity: sensor.fresh_harvest_shopping_window
name: Shopping window
icon: mdi:clock-alert-outline
color: orange
- type: markdown
content: |-
Once an order passes its cutoff it locks for packing, and the following week's cart opens.
[Change this order →](https://freshharvest.com/p/dashboard/manage-orders)