For a long time I used a template that calculated extra print costs (1 euro) for every 10 pages ( = one block) I printed to much, now my printer cost for extra pages went from 1 euro to 1.5 euro.
The template uses an input number that I set in my lovelace.
# The cost of each overprint block, in £
# SET THIS ACCORDING TO YOUR PLAN
hp_printer_pages_overprint_block_cost:
name: "HP Printer - Over Print Block Cost"
min: 0
max: 50
step: 0.01
unit_of_measurement: "EUR"
icon: "mdi:currency-eur"
mode: box
I have changes the input from 1 to 1.5, however the calculation keep setting +1 for every 10 pages (1 block) for overprinting instead of + 1.5.
can someone see whats wrong in this template?
# The cost so far of the pages that have been printed over the standard Available plus Rollover Available
# Calculated when each page is printed, and at the start of each new Instant Ink period
# CHANGE THE CURRENCY CODE AS APPROPRIATE
- name: "HP Printer - Pages Overprint Cost"
unique_id: "template_hp_printer_pages_overprint_cost"
unit_of_measurement: "EUR"
device_class: monetary
state_class: total
icon: "mdi:currency-eur"
state: >
{% if states('sensor.hp_printer_pages_total_printed') or states('input_datetime.hp_printer_this_period_start_date') %}
{% if states('sensor.hp_printer_pages_overprint') | int == 0 %}
0
{% elif states('sensor.hp_printer_pages_overprint') | int > 0 and ( (states('sensor.hp_printer_pages_overprint') | int - 1) % states('input_number.hp_printer_pages_overprint_block_size') | int == 0 ) %}
{{ (1 + ((states('sensor.hp_printer_pages_overprint') | int - 1) / states('input_number.hp_printer_pages_overprint_block_size') | int)) | multiply( states('input_number.hp_printer_pages_overprint_block_cost') | int) | int }}
{% else %}
{{ (1 + ((states('sensor.hp_printer_pages_overprint') | int - 1) / states('input_number.hp_printer_pages_overprint_block_size') | int)) | multiply( states('input_number.hp_printer_pages_overprint_block_cost') | int) | int }}
{% endif %}
{% endif %}
availability: >
{{ is_number(states('sensor.hp_printer_pages_total_printed'))
and has_value('input_datetime.hp_printer_this_period_start_date')
and is_number(states('sensor.hp_printer_pages_overprint'))
and is_number(states('input_number.hp_printer_pages_overprint_block_size'))
and is_number(states('input_number.hp_printer_pages_overprint_block_cost')) }}