Surface add-on prices and add an add-ons total sensor

Add-on rows already carried quantity, unit and extended price; only the name
was exposed. The attribute now renders the full line and a new monetary
sensor reports the add-ons subtotal separately from the box.

The fixture totals were copied from a seven-add-on cart while the fixture
itself had one, so they are now self-consistent and a test asserts that
add-ons plus box price equals the portal's subtotal.
This commit is contained in:
flan
2026-08-03 19:15:19 +00:00
parent a97f0aec6a
commit 527f662189
10 changed files with 174 additions and 32 deletions
+10 -3
View File
@@ -4,7 +4,7 @@
# 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
# editor", and paste this under `views:`. It only needs the six sensors the
# integration creates.
type: sections
@@ -40,6 +40,11 @@ sections:
name: Order total
icon: mdi:cash-multiple
color: teal
- type: tile
entity: sensor.fresh_harvest_next_delivery_add_ons
name: Add-ons
icon: mdi:cart-plus
color: purple
- type: tile
entity: sensor.fresh_harvest_next_delivery_items
name: Items
@@ -55,8 +60,10 @@ sections:
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 [] -%}
{%- set addons_total = state_attr('sensor.fresh_harvest_next_delivery_items', 'add_ons_total') -%}
{%- set box_price = state_attr('sensor.fresh_harvest_next_delivery_items', 'box_price') -%}
{%- if produce -%}
**In the box**
**In the box**{% if box_price %} · ${{ '%.2f' | format(box_price) }}{% endif %}
{% for i in produce %}
- {{ i }}
{%- endfor %}
@@ -64,7 +71,7 @@ sections:
_Box contents not assigned yet._
{%- endif %}
{% if addons %}
**Add-ons**
**Add-ons**{% if addons_total %} · ${{ '%.2f' | format(addons_total) }}{% endif %}
{% for a in addons %}
- {{ a }}
{%- endfor %}