Energy Meter questions

Hi All,

I have a Fronius inverter + solar which I have managed to add to home assistant. The inverter exposes an export price (per kwh rate I get for feeding back to the grid) so that was easy to do, and I am getting accurate export pricing reported in HASS (i.e. it agrees with what my power company says I sent out).

However, two questions remain. One is my rate changes based on the time of day. For e.g. my “peak” rate is $0.15, and my “off peak” rate is between 9PM to 7AM, and is $0.05.

I am trying to manually set up an entity that switches itself based on time conditions - so I can use the “Use an entity tracking the total costs” to add this into the energy dashboard. After reading some documentation/community posts I got as far as adding this into my HASS configuration.yaml, and apparently this is supposed to create an entity sensor.energy_price however this sensor doesn’t show up. What am I doing wrong?

template:
  - sensor:
      - name: Energy Price
        unique_id: energy_price
        unit_of_measurement: AUD/kWh
        state: >
          {% set hr = now().hour %}
          {% if (7 <= hr < 21 )  %}
            {{ 0.15}}
          {% else %}
            {{ 0.05}}

Additionally, I also get charged a “daily rate” which is a static charge from the power company, and is charged regardless of how much energy I use. Is it possible to integrate this into the energy dashboard also? If yes, what is the best way to achieve that?

You need to end your if statement. {% endif %}

Ahh of course. I knew it would be something stupidly simple.

Here is the updated code snippet from my configuration.yaml.

template:
  - sensor:
      - name: Energy Price
        unique_id: energy_price
        unit_of_measurement: AUD/kWh
        state: >
          {% set hr = now().hour %}
          {% if (7 <= hr < 21 )  %}
            {{ 0.15 }}
          {% else %}
            {{ 0.05 }}
          {% endif %}