Too frequent reconnections to Tibber websocket API
Opened this issue · 10 comments
Hi!
We're seeing a big number of web socket reconnects using user agent Domoticz/1.22. I'm assuming I found the correct repo?
Last hour I calculated 420 per hour for one client which is once every ten seconds - that's definitely not intended when using web sockets. You should connect only once and then listen to the data sent by the server.
Do you need any help fixing the client?
See best practices here: https://developer.tibber.com/docs/guides/calling-api
I'm only guessing here but it could be that something like this happens?
- Client connects
- Client waits for one data package
- Server pushes a package
- Client disconnects
- Client waits for 10 seconds
- Go to 1
This is what should happen:
- Client connects
- Client waits for data
- Server pushes a package
- Go to 2
Yes that is how I did.
I don't use this anymore myself, all help is welcomed.
I have never script a websocket that is still online after data is received and don't have time to learn.
It looks like connection is closed every time a message is received? https://github.com/flopp999/Tibber-Domoticz/blob/main/plugin.py#L325
It looks like connection is closed every time a message is received? https://github.com/flopp999/Tibber-Domoticz/blob/main/plugin.py#L325
I am not sure that I use that. I just copied from an employee from Tibber to fix it quickly.
I am not sure that I use that. I just copied from an employee from Tibber to fix it quickly.
If you got code from Tibber it probably might have originated from me. But disconnecting after every call back is definitely not correct.
You say that code bit might not be in use. How can I figure out what actually is in use?
On https://github.com/flopp999/Tibber-Domoticz I have done the latest plugin.py in folder domoticz/plugins and requirements.txt. Then I restarted Domoticz. I don't see any difference in the Domoticz log. Every 10 seconds I see Tibber live power updated.
What I can see in Domoticz VoltagePhase 1, VoltagePhase 2 and VoltagePhase 3 is refreshed every 10 seconds. Does that go well in the script?
You say that code bit might not be in use. How can I figure out what actually is in use?
I think what he means to say is that he is not using the plugin himself so he cannot debug and that the has not time available to spent rewriting everything.
I am using the plugin and I think it is very useful. I do not have the Pulse so I dont have realtime data, but getting the hour prices works fine.
I am not a programmer but I can read the code. I went through the program and I dont understand why that disconnect is in the callback. Would removing it change anything to the functionality of the plugin? And change the number of connects?
My system only connects once per hour to get the hour prices.
Do you have any pointers on how should i set up things to run this code on my computer locally?
Install domoticz (www.domoticz.com) on your computer(Windows, Linux or rpi). Make a folder called Tibber-Domoticz in domoticz/plugins. Copy the plugin to domoticz/plugins/Tibber-Domoticz. Start domoticz and head to the hardware page. At the bottom of the page, you can choose a plugin to be installed. Select Tibber and fill in the info needed. Press add and you should find new devices on the setup/devices page. Thanks for having a go trying to fix this plugin.