Hi,
I have set up a manual sensor for water and for gas. They show up in the energy dashboard. Unfortunately, I cannot set the start value to, for example, 1790 m3 in my configuration. This leads to a consumption of 1790 m3 for the day. I tried already a lot with “initial”, “offset”, “minimum”, but with no success. My last configuration.yaml entry looks like this:
input_number:
gas_meter_reading:
name: Gas Meter Reading
min: 2907
max: 99999
step: 0.001
unit_of_measurement: m³
initial: 2907
water_meter_reading:
name: Water Meter Reading
min: 1790
max: 99999
step: 0.001
unit_of_measurement: m³
initial: 1790
template:
- sensor:
- name: "Gas Daily Consumption"
unique_id: gas_daily_consumption
device_class: gas
state_class: total
unit_of_measurement: "m³"
state: >
{% set now = now() %}
{% set last_reset = states('sensor.gas_last_reset') %}
{% if now.strftime('%Y-%m-%d') != last_reset %}
{% set value = 0 %}
{% else %}
{% set value = states('sensor.gas_daily_consumption') | float(0) %}
{% endif %}
{% set current = states('input_number.gas_meter_reading') | float %}
{% set initial = states('sensor.gas_daily_initial') | float(current) %}
{{ (value + current - initial) | round(3) }}
attributes:
last_reset: "{{ now().strftime('%Y-%m-%d') }}"
initial_reading: "{{ states('input_number.gas_meter_reading') }}"
- name: "Water Daily Consumption"
unique_id: water_daily_consumption
device_class: water
state_class: total
unit_of_measurement: "m³"
state: >
{% set now = now() %}
{% set last_reset = states('sensor.water_last_reset') %}
{% if now.strftime('%Y-%m-%d') != last_reset %}
{% set value = 0 %}
{% else %}
{% set value = states('sensor.water_daily_consumption') | float(0) %}
{% endif %}
{% set current = states('input_number.water_meter_reading') | float %}
{% set initial = states('sensor.water_daily_initial') | float(current) %}
{{ (value + current - initial) | round(3) }}
attributes:
last_reset: "{{ now().strftime('%Y-%m-%d') }}"
initial_reading: "{{ states('input_number.water_meter_reading') }}"
- name: "Gas Last Reset"
unique_id: gas_last_reset
state: "{{ now().strftime('%Y-%m-%d') }}"
- name: "Water Last Reset"
unique_id: water_last_reset
state: "{{ now().strftime('%Y-%m-%d') }}"
- name: "Gas Daily Initial"
unique_id: gas_daily_initial
state: "{{ states('input_number.gas_meter_reading') }}"
- name: "Water Daily Initial"
unique_id: water_daily_initial
state: "{{ states('input_number.water_meter_reading') }}"
Has anybody a clue how I can start with 0 consumption?