I see many people asking this question are pointed to the statistics module or utility meter, but the fact it still not trivial action surprises me greatly. I like many other people on this forum would like to use a graph with differential, delta or relative values with respect to the last value in the graph. For example a DSMR smart meter has the values of energy production and consumption in kWh, but does not have the current consumption. The desired graph would be the currentvalue - lastvalue, giving delta update. This would also allow mixing tarif 1 and tarif 2 in the same graph with results that make sense. I have tried several guides from this forum for example:
- platform: statistics
entity_id:
sensor.energy_consumption_tarif_1
name: c_tarif_1_diff
sampling_size: 1
precision: 4
- platform: statistics
entity_id:
sensor.energy_consumption_tarif_2
name: c_tarif_2_diff
sampling_size: 1
precision: 4
- platform: statistics
entity_id:
sensor.energy_production_tarif_1
name: p_tarif_1_diff
sampling_size: 1
precision: 4
- platform: statistics
entity_id:
sensor.energy_production_tarif_2
name: p_tarif_2_diff
sampling_size: 1
precision: 4
with:
- platform: template
sensors:
power_consumention_watt1:
friendly_name: "Power Consumption Stedin"
unit_of_measurement: 'W'
value_template: "{{ states('sensor.power_consumption') | float * 1000 | round(2) }}"
entity_id:
sensor.power_consumption
power_production_watt1:
friendly_name: "Our Production"
unit_of_measurement: 'W'
value_template: "{{ states('sensor.power_production') | float * 1000 | round(2) }}"
entity_id:
sensor.power_production
c_tarif_1_diff_kwh:
value_template: "{{ state_attr('sensor.c_tarif_1_diff_mean', 'change') }}"
unit_of_measurement: 'kWh'
c_tarif_2_diff_kwh:
value_template: "{{ state_attr('sensor.c_tarif_2_diff_mean', 'change') }}"
unit_of_measurement: 'kWh'
p_tarif_1_diff_kwh:
value_template: "{{ state_attr('sensor.p_tarif_1_diff_mean', 'change') }}"
unit_of_measurement: 'kWh'
p_tarif_2_diff_kwh:
value_template: "{{ state_attr('sensor.p_tarif_2_diff_mean', 'change') }}"
I kept the first example to convert kW to W, since that also took me an hour to do right
Sadly any of the c_kwh and p_kwh values remain zero.
The input does seem to be present.
My questions: what is wrong in the current configuration? Can the utility example be extended with current usage at the same interval as the input data?