Sensor to track average daily electricity cost

I have tried adding/creating a sensor that can track the average of another sensor for a few weeks now with no success. There are no errors in my logs that can tell me what is going on. Any insight would be helpful. Below are two different ways that I have tried to create the sensor. I did let each run for two weeks to see if any data gets created eventually but I don’t even get a sensor in my entities list.

Method one:

  - platform: history_stats
    name: "Average Daily Electricity Cost History"
    entity_id: sensor.daily_electricity_cost
    state: "on"
    type: mean
    start: "{{ now().replace(hour=0, minute=0, second=0) - timedelta(days=7) }}"
    end: "{{ now().replace(hour=0, minute=0, second=0) }}"
      days: 1

Method 2:

  - platform: average
    name: 'Average Daily Electricity Cost'
      days: 7
      - sensor.daily_electricity_cost

I am facing the same problem.
Have you found a solution?

Unfortunately I have not. I moved on for now and patiently wait for someone to share the why here in the future.