home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
71.67k stars 29.95k forks source link

Tibber integration is not updated / devices removed #81037

Closed unik42 closed 1 year ago

unik42 commented 1 year ago

The problem

Tibber does not update any sensors. After removal of Tibber and reinstallalation, no devices or entities are populated. It is quite simply blank. 2022-10-26 (2)

What version of Home Assistant Core has the issue?

Home Assistant 2022.10.4

What was the last working version of Home Assistant Core?

Home Assistant 2022.10.4

What type of installation are you running?

Home Assistant OS

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

home-assistant[bot] commented 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!

Code owner commands Code owners of `tibber` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Change the title of the issue. - `@home-assistant unassign tibber` Removes the current integration label and assignees on the issue, add the integration domain after the command.

(message by CodeOwnersMention)


tibber documentation tibber source (message by IssueLinks)

Danielhiversen commented 1 year ago

Could you share the diagnostic information? Or any relevant logs?

unik42 commented 1 year ago

If you tell me where to look.

unik42 commented 1 year ago

config_entry-tibber-42014b13235f5c8970430d4b02f201b9.json.txt

Danielhiversen commented 1 year ago
  "data": {
    "homes": {}
  }

So seems that the Tibber api does not return any homes for your account.

unik42 commented 1 year ago

I have one home for my Tibber account and one secondary for some heaters at my cabin. Could it be that the reason is that I have two homes?

Danielhiversen commented 1 year ago

Do not think so.

Do you see your homes if you test this query at https://developer.tibber.com/explorer ?

{
  viewer {
    homes {
      address {
        address1
      }
    }
  }
}
unik42 commented 1 year ago

Yes. Both homes show up.

Danielhiversen commented 1 year ago

Hmm, then I do not know what is wrong.

unik42 commented 1 year ago

I'll contact Tibber and ask them to remove the cabin from the app.

patstave commented 1 year ago

Same issue for me. Problem started at 2022-10-26 07:33 (UTC+2).

uffeg68 commented 1 year ago

Same problem here, sensors not updated. Have not reinstalled integration but sensors starts working after reload of integration. Updating of sensors stops after a while (3-4 hours), have to reload again. Very strange.

Danielhiversen commented 1 year ago

Any Tibber errors in the log?

biopixen commented 1 year ago

Same issue for me. Error in the homeassistant.log: 2022-10-27 22:54:52.348 ERROR (MainThread) [tibber] Error connecting to Tibber, resp code: 429 2022-10-27 22:54:52.391 ERROR (MainThread) [tibber] Error connecting to Tibber, resp code: 429 2022-10-27 22:54:52.393 INFO (MainThread) [homeassistant.components.sensor] Setting up sensor.tibber 2022-10-27 22:54:52.395 INFO (MainThread) [homeassistant.components.notify] Setting up notify.tibber

Danielhiversen commented 1 year ago

Error connecting to Tibber, resp code: 429

Indicate that the integration hit some rate limiting, and is blocked.

unik42 commented 1 year ago

When I try the query now, it only says: "Network error: Failed to fetch"

klaparp commented 1 year ago

I have the exact same problem. @Danielhiversen just reach out if you need anything to troubleshoot.

jornodberg commented 1 year ago

Both me and a friend experiences the same. The Tibber-integration suddenly stops receiving/polling data, but after a restart of the integration it starts again. Have Tibber started rate-limiting?

Found this in the logs: 2022-10-25 22:16:39.482 ERROR (MainThread) [tibber] Error connecting to Tibber, resp code: 502

After this occurred, the integration never did fetch any new data until I manually restarted a couple days later.

klaparp commented 1 year ago

It seems the problem ocurred at the same time for everyone so this is probebly related to something tibber did. Sholudnt be too hard to figure out

chhenni commented 1 year ago

Unsure if the problem I have is the same, but I have a fresh install of homeassistant. When I added the tibber integration, it seems to be successfully added, but no devices show up. When I reload the tibber integration I get the following line in the console log

2022-10-28 08:40:11.285 ERROR (MainThread) [tibber] Error connecting to Tibber, resp code: 400

I also tried to run the gql query from this comment: https://github.com/home-assistant/core/issues/81037#issuecomment-1292441755, and it did successfully show my home.

I am unsure if this is the same issue as the rest in the thread or a new, as I seem to be the only one with the 400 status codes Adding it here since all the other symptoms are the same

unik42 commented 1 year ago

Where do you see the error message? The same happens to mine but I cant find where the error message should be.

chhenni commented 1 year ago

Where do you see the error message? The same happens to mine but I cant find where the error message should be.

Easiest is under settings, on the menu there there is an entry named System. Within that menu you should find Logs

unik42 commented 1 year ago

Thanks!

Logger: tibber Source: components/tibber/init.py:55 First occurred: 10:10:53 (1 occurrences) Last logged: 10:10:53

Error connecting to Tibber, resp code: 429

blazern1980 commented 1 year ago

Same error.

Logger: tibber Source: components/tibber/init.py:55 First occurred: 11:46:51 (1 occurrences) Last logged: 11:46:51

Error connecting to Tibber, resp code: 429

Gaaten commented 1 year ago

Same issue here as well happened just now 13:15 1minute after reloading the integration.. It never recovers after an error.

Logger: graphql_subscription_manager Source: components/tibber/init.py:88 First occurred: 13:15:35 (1 occurrences) Last logged: 13:15:35

Websocket is closed.

jornodberg commented 1 year ago

429 = Too Many Requests

Tibber has definitively started rate-limiting...

My friend gets this error fast on a house with solar panel (more requests), while at my home the plugin works longer before beeing dropped (fewer requests).

larswestman commented 1 year ago

I guess there's some throttling going on at Tibber. This happens to me to and I need to deactivate and activate Tibber to start receiving data again. Unfortunately it doesn't seem to be a way to programatically disable/enable an integration to work around the root cause of this issue. I guess the third best option would be to schedule a reboot of HA.

unik42 commented 1 year ago

I got this message (in Norwegian) from Tibber:

Hei igjen!HA integrasjonen driftes av en privatperson på egent initiativ og har ingen tilknyttning direkte til Tibber, men vi ynskjer å hjelpe så langt kunnskapen vår strekker til Anbefaler å prøve å styre mot HomeID, du kan finne den ved å skrive inn koden under i API explorer: https://developer.tibber.com/explorer {

viewer {

homes{

id

appNickname

}

login

name

}

}

larswestman commented 1 year ago

You can read here about their rate limiting: https://developer.tibber.com/docs/overview

larswestman commented 1 year ago

This seems to be a decent workaround for any integration that needs a reload: https://github.com/home-assistant/core/issues/76491#issuecomment-1288634887

klaparp commented 1 year ago

All i get from api explorer is: "Network error: Failed to fetch"

I deleted the old token and created a new one so nothing is fetching anything thus not exceeding any rate limit.

unik42 commented 1 year ago

@Danielhiversen: Regarding this part in the Tibber response: "Anbefaler å prøve å styre mot HomeID..." Is that something you can implement in Tibber? It still does not work on my part.

Danielhiversen commented 1 year ago

I have no idea what that means

jornodberg commented 1 year ago

So, Tibber have recently added a rate-limit of 100 requests in 5 minutes pr ip-address. That sounds reasonable. I have no idea how many API-calls are done by the Tibber-addon though.

Source: https://developer.tibber.com/docs/overview

matjosoft commented 1 year ago

Have the same problem. Values not updated. Integration stops updating data. Happens every day. Reload integration fixes the problem (most of the times). This makes the integration useless. Rate limit seems like a likely cause.

klaparp commented 1 year ago

My external IP is blocked, forever it seams. I cant even run queries in "api-explorer". If i run through vpn and therefore get some other external ip it works just fine.

bskjon commented 1 year ago

Just had this issue myself after updates from tibber became unstable. From the diagnostics on the integration page it reports: "homes": { "current_home_id": { "last_data_timestamp": null, "has_active_subscription": false, "has_real_time_consumption": false, "last_cons_data_timestamp": null, "country": "NO" }, "old_home_id": { "last_data_timestamp": null, "has_active_subscription": false, "has_real_time_consumption": false, "last_cons_data_timestamp": null, "country": "NO" }

Api Explorer:

{ "data": { "viewer": { "homes": [ { "address": { "address1": "Current Home", "country": "NO", }, "features": { "realTimeConsumptionEnabled": true } }, { "address": { "address1": "Old home", "country": "NO" }, "features": { "realTimeConsumptionEnabled": false } } ] } } } There are no errors in the log as far as I can see

VikingKing commented 1 year ago

I have had this problem for å while. I started reloading the integration ever 4 hours, but I was still losing data. As a workaround I made an automation that reloads the integration if data is not updated for 2 minutes. That works for me.

But if the root cause is that Tibber is rate limiting, then the integration should limit how often it queries the Tibber API. In addition it should pause and retry if it receives an error.

jornodberg commented 1 year ago

I see this 'reload the integration immediately (after a minute or two)'-hack as a potential pitfall. If then rate-limit based on IP, this could potentially kick in some other block. I have seen users report that they're unable to connect anymore without using a VPN - probably because they've been blocked by their own IP.

VikingKing commented 1 year ago

Tibber: "We have recently added a rate limit of 100 requests in 5 minutes per IP address to protect the API". That should amount to one query every 3 seconds. That seems reasonable. The integration could be modified to limit the the numbers of queries to this value?

biopixen commented 1 year ago

Just sent a message to tibber support to ask if the "Network error: Failed to fetch" is indicative of a rate-limit problem and also if there is any perma-ban on ip:s that have reached the limit.

unik42 commented 1 year ago

Logger: tibber Source: components/tibber/init.py:55 First occurred: 13:14:28 (1 occurrences) Last logged: 13:14:28

Error connecting to Tibber, resp code: 429

I am still unable to connect at all. So annoying!

VikingKing commented 1 year ago

@unik42 Have to tried to remove the integration for a while, say a day, and reinstalled it? It may be hammering on the API so much that the rate limit is continuously updating and blocking you.

unik42 commented 1 year ago

I have not, and will do so immediately and try in a couple of days.

patstave commented 1 year ago

Any suggestions on how to implement some sort of rate limiting to the repo?

olekenneth commented 1 year ago

This should not have been made like this is the first place, the code should be parsing the response and have an exponential backoff . Not just hammering the api when the response code is not ok. This time it was a rate limit, next time it's the server struggling (might be the reason for implementing the rate limit init the first place) and then the server will not be able to recover because all the users are hammering it.

Any suggestions on how to implement some sort of rate limiting to the repo?

I haven't looked at the code, I assume it's just to have a longer sleep periode.

clas72 commented 1 year ago

Workaround identified: Only use 1 device to communicate with the API. This also inludes the Tibber App. You can not use tha Tibber App in combination with Home Assistant integration, Home Assistant will hang. As olekenneth says there is most likely some response code that is not taken into consideration.

patstave commented 1 year ago

Workaround identified: Only use 1 device to communicate with the API. This also inludes the Tibber App. You can not use tha Tibber App in combination with Home Assistant integration, Home Assistant will hang. As olekenneth says there is most likely some response code that is not taken into consideration.

Well i only use the HA integration, and i only have one home. I never use the Tibber app. Still i am having the problem several times each day.

ztamas83 commented 1 year ago

Workaround identified: Only use 1 device to communicate with the API. This also inludes the Tibber App. You can not use tha Tibber App in combination with Home Assistant integration, Home Assistant will hang. As olekenneth says there is most likely some response code that is not taken into consideration.

I think you draw conclusions a bit too fast. The root cause has not been identified yet and it is not really a workaround to stop using devices. Workaround in HA is to actually auto-reload the integration via an automation. As for the root cause as you can see from different comments the rate limit is just a part of it.

Once again, there are two types of communication from HA integration to the Tibber API, one is polling via HTTP API (for the price and accumulated consumption, etc. sensors) and one is subscription based via websocket (for real time sensors, like Pulse). The latter one is not using HTTP when already subscribed and still stalls. I cannot say how the Tibber backend handles the throttling, could be that subscription is affected too, but there is no evidence whatsoever so we cannot really point out that as a root cause without more information.

And since we're looking at the HA integration now the solution must be in the integration. It is not a Tibber product hence the integration must constantly evolve and be patched for the changes on the API side.

Back-off and auto-recover would be the best way forward.

unik42 commented 1 year ago

Have had the integration uninstalled this weekend and reinstalled it just now. Still not able to populate devices, and still the following error in the log:

image