Closed BartLH closed 1 year ago
Hey there @danielhiversen, mind taking a look at this issue as it has been labeled with an integration (tibber
) you are listed as a code owner for? Thanks!
(message by CodeOwnersMention)
tibber documentation tibber source (message by IssueLinks)
So if you use this query at https://developer.tibber.com/, you get different values for cost and totalCost?
{
viewer {
homes {
consumption(resolution: HOURLY, last: 100) {
nodes {
cost
totalCost
}
}
}
}
}
Correct!
A sample of the response:
{
"data": {
"viewer": {
"homes": [
{
"consumption": {
"nodes": [
...
{
"cost": 0.0179507856,
"totalCost": -0.003772135530952381
},
{
"cost": 0.0091696946,
"totalCost": -0.012553226530952382
},
{
"cost": 0.0088277728,
"totalCost": -0.01289514833095238
},
{
"cost": 0.1500721376,
"totalCost": 0.12834921646904762
},
{
"cost": 0.2319120969,
"totalCost": 0.2101891757690476
},
{
"cost": 0.0401928846,
"totalCost": 0.01846996346904762
},
{
"cost": 0.0583959068,
"totalCost": 0.03667298566904762
},
...
]
}
}
]
}
}
}
Note that the difference is a constant 2,1722921 cents, and that the totalCost
can go negative due to this when prices are low.
Do you have a PV installed?
The problem
The Tibber integration uses a wrong API field to get cost data for its statistic.
This line https://github.com/home-assistant/core/blob/9dd806278b5f0355536b688134928207a7d33b72/homeassistant/components/tibber/sensor.py#L585 should use
cost
instead oftotalCost
.totalCost
is officially deprecated. See also https://developer.tibber.com/docs/reference#consumption.The issue (in addition to the fact that we shouldn't use deprecated API fields in principle 😉) is that
totalCost
produces an hourly cost that is about 2 cents lower than the actual cost reported in the app, which is how I came to investigate this. I have verified in the API explorer thatcost
produces the same values as those shown in the app and can be used a drop-in replacement.What version of Home Assistant Core has the issue?
2023.2.3
What was the last working version of Home Assistant Core?
No response
What type of installation are you running?
Home Assistant Container
Integration causing the issue
Tibber
Link to integration documentation on our website
https://www.home-assistant.io/integrations/tibber/
Diagnostics information
No response
Example YAML snippet
No response
Anything in the logs that might be useful for us?
No response
Additional information
No response