How are the device and entity IDs formed? Which were converted to cryptic numbers from your automation?
Could you please explain that?
How are the device and entity IDs formed? Which were converted to cryptic numbers from your automation?
Could you please explain that?
I have a senec battery-system. The integration for that gives me a switch that turns on or off manuell loading from grid. Device-entity and entity_id are from the automation-editor in Home Assistant for that switch.
Something doesn’t seem to be 100% right with my configuration, because I don’t get any correct data in the “history”.
Do you have an idea?
Has the forward prices been removed or moved to another entity?
Do you have LTS-data in the normal ha-history view for that enttiy?
I found the error. It was a copy paste transmission error.
Now I’ve made everything work…
…Except for a statistics graph.
Why does “TODAY COSTS” permanently load?
Did I create any utility meter incorrectly?
“tibber kosten daily” doesn’t record anything either…
All other statistics “week, month, year” are running
I do not get hourly data anymore through api since this night. Anyone else is seeing the same “null” inside “sensor.tibber_hourly_consumption”?
- consumption: null
cost: null
unitPrice: 0.3032834
unitPriceVAT: 0.0484234
from: "2024-06-17T23:00:00.000+02:00"
to: "2024-06-18T00:00:00.000+02:00"
- consumption: null
cost: null
unitPrice: 0.2977737
unitPriceVAT: 0.0475437
from: "2024-06-18T00:00:00.000+02:00"
to: "2024-06-18T01:00:00.000+02:00"
same here.
Had the same issue twice since last week. Reboot of HA solves it. I guess a bug in the tibber integration or something like this. In EVCC and the Tibber app itself everything was fine.
Reboot does not help. It’s an issue on Tibber’s API. I tested it on their API explorer: https://developer.tibber.com/explorer
No “cost” and “consumption” data are provided anymore.
I sent them an email, we will see when it’s fixed.
This is what Tibber says about it:
Seems to be working again since 4am.
I created my own Tibber monthly cost sensor because the one provided by the Tibber integration consistently differs from the costs displayed in the app for the current month. This discrepancy occurs because the Tibber integration doesn’t account for certain cost components, such as the ‘metering point fee,’ the ‘Tibber base fee,’ and the ‘grid usage fee.’ I´ve created input_number-helpers for these (you will see in the code below).
Using the Tibber API, I’ve set up the following rest-sensors to retrieve consumption and cost data for the last 31 days and the last 24 hours (the ‘daily’ query via the API doesn’t provide data for today)
- platform: rest
unique_id: tibber_hourly_cost
name: Tibber Hourly Cost
resource: https://api.tibber.com/v1-beta/gql
method: POST
payload: '{ "query": "{ viewer { homes { consumption(resolution: HOURLY, last: 24) { nodes { consumption cost unitPrice unitPriceVAT from to } } } } }" }'
json_attributes_path: "$.data.viewer.homes[0].consumption"
json_attributes:
- nodes
value_template: "{{ value_json.data.viewer.homes[0].consumption.nodes[0].cost | float (default=0) }}"
scan_interval: 300
headers:
Authorization: !secret tibber_token
Content-Type: application/json
unit_of_measurement: EUR
state_class: total
- platform: rest
unique_id: tibber_daily_cost
name: Tibber Daily Cost
resource: https://api.tibber.com/v1-beta/gql
method: POST
payload: '{ "query": "{ viewer { homes { consumption(resolution: DAILY, last: 31) { nodes { consumption cost unitPrice unitPriceVAT from to } } } } }" }'
json_attributes_path: "$.data.viewer.homes[0].consumption"
json_attributes:
- nodes
value_template: "{{ value_json.data.viewer.homes[0].consumption.nodes[0].cost | float (default=0) }}"
scan_interval: 300
headers:
Authorization: !secret tibber_token
Content-Type: application/json
unit_of_measurement: EUR
state_class: total
With this Information you can create a template-sensor (via UI or via YAML) with the following code for the state:
{% set monatskosten = namespace(wert=0) %}
{% set monatsverbrauch = namespace(wert=0) %}
{% for entry in states.sensor.tibber_daily_cost.attributes.nodes %}
{% set from_datetime = as_timestamp(entry.from) %}
{% set to_datetime = as_timestamp(entry.to) %}
{% if as_timestamp(entry.from) | timestamp_custom('%Y-%m') == as_timestamp(now()) | timestamp_custom('%Y-%m') %}
{% set kosten_je_tag = states("input_number.tibber_messtellengebuhr_je_tag") | float(default=0) + states("input_number.tibber_netznutzungsgebuhr_je_tag") | float(default=0) %}
{% set cost_kwh = entry.unitPrice | float(default=0) - entry.unitPriceVAT | float(default=0) %}
{% set consumption_cost = (cost_kwh | float(default=0) * entry.consumption | float(default=0)) %}
{% set monatstage = (now().replace(month=now().month % 12 + 1, day=1) - timedelta(days=1)).day | int(default=0) %}
{% set day_cost = (consumption_cost + (states("input_number.tibber_grundpreis_je_monat") | float(default=0) / monatstage) + kosten_je_tag) | float(default=0) * (states("input_number.tibber_mehrwertsteuersatz") | float(default=0) + 1) %}
{% set monatskosten.wert = monatskosten.wert + day_cost %}
{% set monatsverbrauch.wert = monatsverbrauch.wert + entry.consumption %}
{% endif %}
{% endfor %}
{% set tageskosten = namespace(wert=0) %}
{% set tagesverbrauch = namespace(wert=0) %}
{% for entry in states.sensor.tibber_hourly_cost.attributes.nodes %}
{% set from_datetime = as_timestamp(entry.from) %}
{% set to_datetime = as_timestamp(entry.to) %}
{% if as_timestamp(entry.from) | timestamp_custom('%Y-%m-%d') == as_timestamp(now()) | timestamp_custom('%Y-%m-%d') %}
{% set kosten_je_tag = states("input_number.tibber_messtellengebuhr_je_tag") | float(default=0) + states("input_number.tibber_netznutzungsgebuhr_je_tag") | float(default=0) %}
{% set cost_kwh = entry.unitPrice | float(default=0) - entry.unitPriceVAT | float(default=0) %}
{% set consumption_cost = (cost_kwh | float(default=0) * entry.consumption | float(default=0)) %}
{% set monatstage = (now().replace(month=now().month % 12 + 1, day=1) - timedelta(days=1)).day | int(default=0) %}
{% set hour_cost = (consumption_cost + ((states("input_number.tibber_grundpreis_je_monat") | float(default=0) / monatstage) + kosten_je_tag) | float(default=0) / 24) * (states("input_number.tibber_mehrwertsteuersatz") | float(default=0) + 1) %}
{% set tageskosten.wert = tageskosten.wert + hour_cost %}
{% set tagesverbrauch.wert = tagesverbrauch.wert + entry.consumption %}
{% endif %}
{% endfor %}
{{ monatskosten.wert + tageskosten.wert}}
(i´m sure there is a more elegant way to do this, but this is the way i was able to do it )
As you can see there is only a small difference (0,01 €) betwenn both values.
Great, thank you for your contributions.
Unfortunately I have a price difference of almost 3 euros. Is this still settling, or where is my mistake?
VG Alex
Do your input_select´s values match the values on your last invoice?
Now it fits down to 30 cents, thank you
You can get the total cost in this year in the same way. Here is my code für that:
{% set jahreskosten = namespace(wert=0) %}
{% set jahresverbrauch = namespace(wert=0) %}
{% set monatskosten = namespace(wert=0) %}
{% set monatsverbrauch = namespace(wert=0) %}
{% set tageskosten = namespace(wert=0) %}
{% set tagesverbrauch = namespace(wert=0) %}
{% for entry in states.sensor.tibber_monthly_cost.attributes.nodes %}
{% if as_timestamp(entry.from) | timestamp_custom('%Y') == as_timestamp(now()) | timestamp_custom('%Y') %}
{% set kosten_je_tag = states("input_number.tibber_messtellengebuhr_je_tag") | float(default=0) + states("input_number.tibber_netznutzungsgebuhr_je_tag") | float(default=0) %}
{% set cost_kwh = entry.unitPrice | float(default=0) - entry.unitPriceVAT | float(default=0) %}
{% set consumption_cost = cost_kwh | float(default=0) * entry.consumption | float(default=0) %}
{% set monatstage = (as_datetime(as_timestamp(entry.from)).replace(month=as_datetime(as_timestamp(entry.from)).month % 12 + 1, day=1) - timedelta(days=1)).day | int(default=0) %}
{% set month_cost = (consumption_cost | float(default=0) + (states("input_number.tibber_grundpreis_je_monat") | float(default=0) ) + (kosten_je_tag | float(default=0) * monatstage | float(default=0))) * (states("input_number.tibber_mehrwertsteuersatz") | float(default=0) + 1) %}
{% set jahreskosten.wert = jahreskosten.wert | float(default=0) + month_cost | float(default=0) %}
{% set jahresverbrauch.wert = jahresverbrauch.wert | float(default=0) + entry.consumption | float(default=0) %}
{% endif %}
{% endfor %}
{% for entry in states.sensor.tibber_daily_cost.attributes.nodes %}
{% if as_timestamp(entry.from) | timestamp_custom('%Y-%m') == as_timestamp(now()) | timestamp_custom('%Y-%m') %}
{% set kosten_je_tag = states("input_number.tibber_messtellengebuhr_je_tag") | float(default=0) + states("input_number.tibber_netznutzungsgebuhr_je_tag") | float(default=0) %}
{% set cost_kwh = entry.unitPrice | float(default=0) - entry.unitPriceVAT | float(default=0) %}
{% set consumption_cost = cost_kwh | float(default=0) * entry.consumption | float(default=0) %}
{% set monatstage = (now().replace(month=now().month % 12 + 1, day=1) - timedelta(days=1)).day | int(default=0) %}
{% set day_cost = (consumption_cost | float(default=0) + (states("input_number.tibber_grundpreis_je_monat") | float(default=0) / monatstage | float(default=0)) + kosten_je_tag | float(default=0)) * (states("input_number.tibber_mehrwertsteuersatz") | float(default=0) + 1) %}
{% set monatskosten.wert = monatskosten.wert | float(default=0) + day_cost | float(default=0) %}
{% set monatsverbrauch.wert = monatsverbrauch.wert | float(default=0) + entry.consumption | float(default=0) %}
{% endif %}
{% endfor %}
{% for entry in states.sensor.tibber_hourly_cost.attributes.nodes %}
{% if as_timestamp(entry.from) | timestamp_custom('%Y-%m-%d') == as_timestamp(now()) | timestamp_custom('%Y-%m-%d') %}
{% set kosten_je_tag = states("input_number.tibber_messtellengebuhr_je_tag") | float(default=0) + states("input_number.tibber_netznutzungsgebuhr_je_tag") | float(default=0) %}
{% set cost_kwh = entry.unitPrice | float(default=0) - entry.unitPriceVAT | float(default=0) %}
{% set consumption_cost = cost_kwh| float(default=0) * entry.consumption | float(default=0) %}
{% set monatstage = (now().replace(month=now().month % 12 + 1, day=1) - timedelta(days=1)).day | int(default=0) %}
{% set hour_cost = (consumption_cost| float(default=0) + ((states("input_number.tibber_grundpreis_je_monat")| float(default=0) / monatstage| float(default=0)) + kosten_je_tag| float(default=0)) / 24) * (states("input_number.tibber_mehrwertsteuersatz")| float(default=0) + 1) %}
{% set tageskosten.wert = tageskosten.wert + hour_cost| float(default=0) %}
{% set tagesverbrauch.wert = tagesverbrauch.wert + entry.consumption| float(default=0) %}
{% endif %}
{% endfor %}
{{ (jahreskosten.wert + monatskosten.wert + tageskosten.wert) | round(2) }}
for that you also need a monthly-rest-sensor like this:
# Tibber Monthly Cost Sensor
- platform: rest
unique_id: tibber_monthly_cost
name: Tibber Monthly Cost
resource: https://api.tibber.com/v1-beta/gql
method: POST
payload: '{ "query": "{ viewer { homes { consumption(resolution: MONTHLY, last: 12) { nodes { consumption cost unitPrice unitPriceVAT from to } } } } }" }'
json_attributes_path: "$.data.viewer.homes[0].consumption"
json_attributes:
- nodes
value_template: "{{ value_json.data.viewer.homes[0].consumption.nodes[0].cost | float (default=0) }}"
scan_interval: 300
headers:
Authorization: !secret tibber_token
Content-Type: application/json
unit_of_measurement: EUR
state_class: total
Does anyone have an idea how to ensure that two decimal places are always displayed, even if they are zero?
Hello @ingo.niehues,
i have tried to add your cards to my home assistant installation, but i’m having some issues/questions.
for the hourly, daily, monthly, year consumption i already have some entities from my tasmota sensor…
if i choose them i wan’t get a graph in the diagramm…
See the first picture.
And in the “Verlauf” i also have no graph.
The Restsensor “tibber_prices” i have already configured.
maybe someone can help me out here…
Mit freundlichen Grüßen
Chris