Statistics Graph Card - Unable to select state for stat_type.
- name: Daily Return on Investment
unique_id: daily_return_on_investment
unit_of_measurement: AUD
state_class: measurement
state: |
{% set total = 0 | float %}
{% set answer = states('sensor.daily_solar_energy_to_load_roi') %}
{% if is_number(answer) %}{% set total = total + answer | float %}{% endif %}
{% set answer = states('sensor.daily_battery_return_on_investment') %}
{% if is_number(answer) %}{% set total = total + answer | float %}{% endif %}
{% set answer = states('sensor.daily_mains_export_feed_in_return') %}
{% if is_number(answer) %}{% set total = total + answer | float %}{% endif %}
{{ total }}
icon: mdi:currency-usd
- name: Daily Cost
unique_id: daily_cost
unit_of_measurement: AUD
state_class: measurement
state: |
{% set total = 0 | float %}
{% set answer = states('sensor.daily_mains_energy_import_cost') %}
{% if is_number(answer) %}{% set total = answer | float %}{% endif %}
{% set answer = states('sensor.daily_electricity_supply_charge') %}
{% if is_number(answer) %}{% set total = total + answer | float %}{% endif %}
{{ total }}
icon: mdi:currency-usd
- name: Daily Bill Cost
unique_id: daily_bill_cost
unit_of_measurement: AUD
state_class: measurement
state: |
{% set total = 0 | float %}
{% set answer = states('sensor.daily_cost') %}
{% if is_number(answer) %}{% set total = answer | float %}{% endif %}
{% set answer = states('sensor.daily_mains_export_feed_in_return') %}
{% if is_number(answer) %}{% set total = total - answer | float %}{% endif %}
{{ total }}
icon: mdi:currency-usd
which I am trying to graph with the cost which should show the state at midnight and the daily totals reset to zero, caused by the reset of the source sensors.
The graph is:
chart_type: bar
period: day
type: statistics-graph
entities:
- sensor.daily_cost
- sensor.daily_bill_cost
- sensor.daily_return_on_investment
days_to_show: 7
title: Daily Costs
hide_legend: false
stat_types:
- max
I am unable to set the stat_type to state. Why?