-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Loosing connection all the time #2
Comments
Hi, |
Same problem here, due to this, my graphs look like this: I even have fixed IP for it. EDIT: tried to raise socket timeout from 10 seconds to 30, huge improvement, only failing once in a while. I'm now trying 55 seconds and will let know. I also tried to spam it every 5 seconds for a while - responded immediately everytime! I also found in the Android app code that they are using only 1 second timeout for the query request:
so they are too spamming it every 5 seconds :) You can try yourself if you want: import socket
from time import sleep
# retry method
def with_retry(func, *args, **kwargs):
max_retries = 3
for _ in range(max_retries):
try:
return func(*args, **kwargs)
except OSError as e:
sleep(5) # delay between retries, probably not important
raise Exception(f"Failed after {max_retries} retries")
def query():
try:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.settimeout(1) # socket timeout
s.connect(('10.0.2.11', 80))
s.send(b'["SEL","0"]')
response = s.recv(1024)
decoded = response.decode()
print(decoded)
finally:
try:
s.close()
except:
pass
for i in range(100):
with_retry(query)
print(i)
sleep(5) # delay between requests Anyway, so far with 55 seconds timeout no problem for me: Now the real question is: what do we want to do? Even 15 seconds between requests fail for me, we would need to lower down to 10 (10 looks like is enough) and that's IMO pointless to spam it every 10 seconds 24/7. So, let it sleep and set 1 minute timeout for wake up? And one more thing - in this piece of code: try:
async with timeout(10):
d = await self.hass.async_add_executor_job(_update_data)
return d
except Exception as error:
raise UpdateFailed(f"Invalid response from API: {error}") from error
However I don't know how HASS integration works, if we have 1 minute update interval, can we have longer timeout? Will HASS wait or send another update before this one finishes? |
@ruialmeidinha you can try my fork.
Sometimes it still timeouts, but for now less than 10 times per day, hence the last valid value logic: You can just replace |
Hi @leoshusar I have copied both const.py and coordinator.py files from your fork, to my custom componets folder. The behaviour is exactly the same.... Did I do what was expected, or did I do something wrong ? Thanks in advance, |
No problem! You have to replace existing files and then restart Home Assistant so it actually loads them. Did you do this? |
Yes, I did ! |
Hmm, what is in your logs? |
4HEAT - Salamandra Pellets Combustion power changed to 120 |
Can you please explain me what are all these entities/ sensors eg. UN 20118, UN 20119, etc ? Almost 30 of them... Thanks |
Hi
I have installed this add on 3 days ago.
First of all it worked
Immediately as i Have placed the ip address of the 4 heat module of my stove.
i got immediately all the readings
However, it only works randomly as the connection “comes and goes”
This is the image of “right now”:
Should i place a fixed ip address for the 4heat module in stove in the router ?
I have everything with the latest software
4heat module
Home assistant
Integration of 4heat
thanks in advance !!!
👌🙌
The text was updated successfully, but these errors were encountered: