TheBrain8791 / ha_awattar

Adds Awattar energy cost data to Home Assistant.
Other
11 stars 1 forks source link

ct / kWh leads to wrong price calculations #6

Open gerione opened 1 year ago

gerione commented 1 year ago

With the ct/kWh price it leads to wrong calculations. I got 3,69 kWh and 47,68 € instead of 0,4768 €. Somehow ct/kWh is not recognised in Home Assistant. Maybe a second sensor with €/kWh would be good.

SilverFolfy commented 3 months ago

Sorry for the necro, but I also hope this can be made a standard sensor in this project (and other similar ones) so we can just plop it into the energy dashboard as-is so the cost tracking is working as expected. So a solution for anyone also stumbling upon this: I made my own template sensor in my HA configuration.yaml that takes the value and just divides it by 100. Maybe not the most efficient but it works:

template:
  - sensor:
      - name: "Awattar AT Price €/kWh"
        unique_id: awattar_at_price_custom
        unit_of_measurement: "€/kWh"
        icon: "mdi:currency-eur"
        state: >
            {%- if states('sensor.awattar_at_price') != 'unavailable' %}
               {%- set awattar_cent = states('sensor.awattar_at_price') | float %}
               {%- set value = awattar_cent / 100 | float %}
               {{ value }}
            {%- else %}
               {{ 0 }}
            {%- endif  #%}