Brand new noob - having a go at my first integration - energy - nearly there!

Greetings,

My first post here.

I’ve been following this article by James Ridgeway to integrate a Shelly EM2 into HA:
Energy Monitoring with Shelly EM and Home Assistant (jamesridgway.co.uk)

The Shelly EM is working and I’ve had data coming in for about 2 weeks now.
However I’ve been struggling to get the UK Electricity Standing Charge working.

Here are my configs:

configuration.yaml:
# Loads default set of integrations. Do not remove.`
default_config:

# Text to speech
tts:
’ - platform: google_translate’

automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
sensor: !include sensors.yaml
`

templates.yaml:
`

  • sensor:
    • name: “Standing Charge Energy”
      unit_of_measurement: “kWh”
      device_class: energy
      state_class: total_increasing
      state: >-
      {{ (((now().timestamp() / 3600) - 1664044509) | int) / 1000}}
      attributes:
      last_reset: ‘1970-01-01T00:00:00+00:00’
      `

sensors.yaml:
`

  • platform: template
    sensors:
    electricity_kwh_unit_price:
    friendly_name_template: “Electricity Unit Price”
    value_template: “0.23180”
    unit_of_measurement: “£/kWh”
    electricity_standing_charge_price:
    friendly_name_template: “Electricity Standing Charge Price”
    value_template: “10.94875” # (£0.26277 per day * 1000) / 24
    unit_of_measurement: “GBP/kWh”
    `

The issue:

The final part of the process is to add the standing charge sensor to the Energy Dashboard.
When I Add Consumption ‘Standing Charge Energy’ does not appear in the Top drop list from templates.yaml.

When I click on the ‘Use an entity with current price’ radio button I can see both Electricity Unit Price & Electricity Standing Charge Price from sensors.yaml.

I’ve restarted HA, I’ve reloaded the template and no dice.

I’ve obviously missed something crucial here.
Could anyone provide any pointers please?

The help at the bottom of the list is of no help at all - just says this:

“Expected data source not listed
You’re configuring a statistic but you couldn’t find your source in the dropdown?
That’s caused by a bug in the integration providing the entity.
Integrations need to configure their entities correctly so Home Assistant knows that we need to track statistics for it and how.”

I apologise for the code formatting.
I tried enclosing it with the ` key but it just came out weird.

How do you guys post the code so nicely?

Cheers
-s

https://community.home-assistant.io/t/how-to-help-us-help-you-or-how-to-ask-a-good-question/114371#oneone-format-it-properly-16

Thanks Tom,
Hopefully this should be correctly formatted

configuration.yaml

# Loads default set of integrations. Do not remove.
default_config:

# Text to speech
tts:
  - platform: google_translate

automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
sensor: !include sensors.yaml

templates.yaml

- sensor:
  - name: "Standing Charge Energy"
    unit_of_measurement: "kWh"
    device_class: energy
    state_class: total_increasing
    state: >-
      {{ (((now().timestamp() / 3600) - 1664044509) | int) / 1000}}
    attributes:         
      last_reset: '1970-01-01T00:00:00+00:00'
      

sensors.yaml

- platform: template
  sensors:
    electricity_kwh_unit_price:
      friendly_name_template: "Electricity Unit Price"
      value_template: "0.23180"
      unit_of_measurement: "£/kWh"
    electricity_standing_charge_price:
      friendly_name_template: "Electricity Standing Charge Price"
      value_template: "10.94875" # (£0.26277 per day * 1000) / 24
      unit_of_measurement: "GBP/kWh"