Closed Veldkornet closed 3 years ago
I'm seeing the same errors, but I don't think I can fix this... After some search I found this error is thrown when the server could not be reached https://github.com/barban-dev/homeassistant-midea-dehumidifier/issues/10
I suspected that it might be that... any way though that a friendlier error can be printed though so that we don't get this massive error on repeat the whole time? :)
Just wanted to open issue for the same thing. Around 400 error messages the last 20hrs. :( I hope there will be a (friendlier) solution.
Not sure if I'm comparing pears with apples here, but I have the following sensor (Also looking at buienalarm) for a neerslag card, and it doesn't seem to give any errors...
- platform: command_line
command: python3 -c "import requests; import json; import random; dataRequest = requests.get('https://cdn-secure.buienalarm.nl/api/3.4/forecast.php?lat={{state_attr("zone.home", "latitude") | round(3)}}&lon={{state_attr("zone.home", "longitude") | round(3)}}®ion=nl&unit=mm%2Fu&c='+str(random.randint(0,999999999999999)) ).text; dataRequest = dataRequest.replace('\r\n',' '); data = '{\"data\":'+dataRequest+'}'; print(data);"
name: Neerslag_Buienalarm_Regen_Data
json_attributes:
- data
value_template: "last_changed: {{states.sensor.neerslag_buienalarm_regen_data.last_changed | default(now())}}"
scan_interval: 240
I'm seeing the same errors, but I don't think I can fix this... After some search I found this error is thrown when the server could not be reached barban-dev/homeassistant-midea-dehumidifier#10
So, is this integration broken beyond repair then? For me it doesn't work anymore.
I had a look myself as I was getting nuts with all of the errors. I've noticed that Buienalarm throws a "502 bad gateway" for whatever reason. I think what could be a simple fix to limit the amount of errors is by checking the status code returned by Buienalarm before actually performing an action on the data.
So here https://github.com/gieljnssns/buienalarm/blob/master/buienalarm/pybuienalarm.py#L81 add something like
if response.status_code != 200:
It only means that the data is not updated, but in the current way it isn't anyway, but at least all errors are gone 😅
@peternijssen Were you able to solve it by adding the code above?
Yeah that seems to work. Still checking as I recently changed it. This is how the try / catch block currently looks like;
try:
resp = requests.get(self.__REQUEST_URL, params=payload)
if resp.ok:
data = resp.json()
if data["success"] is False:
LOG.error(data.get("reason"))
else:
self.data = data
else:
LOG.error("Failed to get a response from Buienalarm. Response code: " + str(resp.status_code))
except requests.exceptions.RequestException as e:
LOG.error(e)
Bad part is that I had to change this in the library, but it's a starting point to try and then I can add a PR to the original library. Unless the author wants to fix it :)
I'm open for a PR. I don't have the time to do it myself.
Pushed the change to the library. I wonder if we also should make sure that after a failure, it just continues with the old data perhaps. Since it failed to update, the next sensor will just try again and fail again, thus leading to the same error happening over and over again in the same second. Perhaps we should set the renew time to now + 10 seconds.
I’m started getting errors (my log is basically spammed with it) with this sensor as of HA 2021.04, add-on version 1.5: