How to get an entity for use in entity card that shows previous day values

I have an entity card on a dashboard showing todays values for power, gas and water, by way of Utility Meter helper entities. I would also like to display these values for the day before. What would be the easiest way to accomplish this?

Would using a statistics card be an option?

 - type: statistic
   name: Consumption today
   entity: sensor.gasmeter_kwh
   period:
    calendar:
      period: day
      offset: 0
   stat_type: change
  
  - type: statistic
    name: Consumption yesterday
    entity: sensor.gasmeter_kwh
    period:
     calendar:
       period: day
       offset: -1
    stat_type: change
1 Like

That does work, always good to know of another way to do things.

However I really like the entities card layout better, where I also use the custom lovelace-multiple-entity-row row element to keep it compact. Is there a way to do this with an entity card?

I managed to get this by creating number helper entities and setting these entities with an automation each day at 23:59:50 with the value of the current day entity:

alias: Set daily utility values
description: ""
trigger:
  - platform: time_pattern
    hours: "23"
    minutes: "59"
    seconds: "50"
condition: []
action:
  - service: input_number.set_value
    target:
      entity_id: input_number.electricity_from_grid_yesterday
    data_template:
      value: "{{ float(states('sensor.electricity_from_grid_today')) }}"
  - service: input_number.set_value
    target:
      entity_id: input_number.electricity_from_solar_yesterday
    data_template:
      value: "{{ float(states('sensor.electricity_from_solar_today')) }}"
  - service: input_number.set_value
    target:
      entity_id: input_number.electricity_to_grid_yesterday
    data_template:
      value: "{{ float(states('sensor.electricity_to_grid_today')) }}"
  - service: input_number.set_value
    target:
      entity_id: input_number.water_used_yesterday
    data_template:
      value: "{{ float(states('sensor.water_used_today')) }}"
  - service: input_number.set_value
    target:
      entity_id: input_number.gas_used_yesterday
    data_template:
      value: "{{ float(states('sensor.daily_gas_v2')) }}"
mode: single

Then with the help of the lovelace-multiple-entity-row addon created this card:

image

1 Like