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
72.31k stars 30.26k forks source link

rest sensor unavailable #43600

Closed mogensboegh closed 3 years ago

mogensboegh commented 3 years ago

The problem

Environment

Problem-relevant configuration.yaml

Traceback/Error logs

Additional information

Hi It seems i am stuck with HA 116.4 I run HA on raspberry pi3+ with virtual environment. I have done this for years since version 60 something. I am also a Nabu Casa customer. I have lots of sensors, binary sensors, scripts, switches and automations. Everything went fine until i tried to upgrade to the first 117 After an upgrade HA starts but my REST sensors create trouble. Some of them - not all - become "unavailable" I can't believe i am the only one with this problem, but maybe i am It doesn't matter which 117.x i try to upgrade to I have not tried 118.x yet as i expect same result after many upgrade attempts with 117.x Anyway i seem stuck so i must ask for assistance. I have set up a HA on another raspberry pi3+ to have a controlled environment in order to make the problem reproduceable. In this environment i have 5 rest sensors - nothing else. If i only have 4 there is no problem The very moment i add the 5th sensor one of the 5 become "unavailable" To me it looks like HA picks one of them randomly. It is not consequently the same one of the 5 that becomes unavailable. If i add further rest sensors, all but 4 sensors become unavailable. It seems as if there was a limit of 4 sensors. I have included:

HA [frontend]

frontend

sensors.yaml

The answer from my arduino from one of the sensors that work and the answer from the one that dosn't in a dosprompt It doesn't matter from which computer the curl statement is issued.

dosprompt

The HA log In this it looks like the HA thinks i sends a curl to the sensor (without actually doing so) and then complains over the lack of answer. The text "Error fetching data: http://192.168.1.100/A failed with " i guess should give some information but doesn't

2020-11-24 12:33:20 WARNING (MainThread) [homeassistant.components.sensor] Setup of sensor platform rest is taking over 10 seconds. 2020-11-24 12:33:20 ERROR (MainThread) [homeassistant.components.rest.data] Error fetching data: http://192.168.1.100/B failed with 2020-11-24 12:33:20 WARNING (MainThread) [homeassistant.components.sensor] Platform rest not ready yet. Retrying in 30 seconds. 2020-11-24 12:33:20 WARNING (MainThread) [homeassistant.bootstrap] Support for the running Python version 3.7.3 is deprecated and will be removed in the first release after December 7, 2020. Please upgrade Python to 3.8.0 or higher. 2020-11-24 12:34:21 WARNING (MainThread) [homeassistant.helpers.entity] Update of sensor.vp_fremloeb is taking over 10 seconds 2020-11-24 12:34:21 ERROR (MainThread) [homeassistant.components.rest.data] Error fetching data: http://192.168.1.100/A failed with 2020-11-24 12:34:51 WARNING (MainThread) [homeassistant.helpers.entity] Update of sensor.vp_fremloeb is taking over 10 seconds 2020-11-24 12:34:51 ERROR (MainThread) [homeassistant.components.rest.data] Error fetching data: http://192.168.1.100/A failed with 2020-11-24 12:35:21 WARNING (MainThread) [homeassistant.helpers.entity] Update of sensor.vp_fremloeb is taking over 10 seconds 2020-11-24 12:35:21 ERROR (MainThread) [homeassistant.components.rest.data] Error fetching data: http://192.168.1.100/A failed with 2020-11-24 12:35:51 WARNING (MainThread) [homeassistant.helpers.entity] Update of sensor.vp_fremloeb is taking over 10 seconds 2020-11-24 12:35:51 ERROR (MainThread) [homeassistant.components.rest.data] Error fetching data: http://192.168.1.100/A failed with 2020-11-24 12:36:21 WARNING (MainThread) [homeassistant.helpers.entity] Update of sensor.vp_fremloeb is taking over 10 seconds 2020-11-24 12:36:21 ERROR (MainThread) [homeassistant.components.rest.data] Error fetching data: http://192.168.1.100/A failed with 2020-11-24 12:36:51 WARNING (MainThread) [homeassistant.helpers.entity] Update of sensor.vp_fremloeb is taking over 10 seconds 2020-11-24 12:36:51 ERROR (MainThread) [homeassistant.components.rest.data] Error fetching data: http://192.168.1.100/A failed with 2020-11-24 12:37:21 WARNING (MainThread) [homeassistant.helpers.entity] Update of sensor.vp_fremloeb is taking over 10 seconds 2020-11-24 12:37:21 ERROR (MainThread) [homeassistant.components.rest.data] Error fetching data: http://192.168.1.100/A failed with 2020-11-24 12:37:51 WARNING (MainThread) [homeassistant.helpers.entity] Update of sensor.vp_fremloeb is taking over 10 seconds 2020-11-24 12:37:51 ERROR (MainThread) [homeassistant.components.rest.data] Error fetching data: http://192.168.1.100/A failed with 2020-11-24 12:38:21 WARNING (MainThread) [homeassistant.helpers.entity] Update of sensor.vp_fremloeb is taking over 10 seconds 2020-11-24 12:38:21 ERROR (MainThread) [homeassistant.components.rest.data] Error fetching data: http://192.168.1.100/A failed with 2020-11-24 12:38:51 WARNING (MainThread) [homeassistant.helpers.entity] Update of sensor.vp_fremloeb is taking over 10 seconds 2020-11-24 12:38:51 ERROR (MainThread) [homeassistant.components.rest.data] Error fetching data: http://192.168.1.100/A failed with 2020-11-24 12:39:21 WARNING (MainThread) [homeassistant.helpers.entity] Update of sensor.vp_fremloeb is taking over 10 seconds 2020-11-24 12:39:21 ERROR (MainThread) [homeassistant.components.rest.data] Error fetching data: http://192.168.1.100/A failed with 2020-11-24 12:39:51 WARNING (MainThread) [homeassistant.helpers.entity] Update of sensor.vp_fremloeb is taking over 10 seconds 2020-11-24 12:39:51 ERROR (MainThread) [homeassistant.components.rest.data] Error fetching data: http://192.168.1.100/A failed with 2020-11-24 12:40:21 WARNING (MainThread) [homeassistant.helpers.entity] Update of sensor.vp_fremloeb is taking over 10 seconds 2020-11-24 12:40:21 ERROR (MainThread) [homeassistant.components.rest.data] Error fetching data: http://192.168.1.100/A failed with 2020-11-24 12:40:51 WARNING (MainThread) [homeassistant.helpers.entity] Update of sensor.vp_fremloeb is taking over 10 seconds 2020-11-24 12:40:51 ERROR (MainThread) [homeassistant.components.rest.data] Error fetching data: http://192.168.1.100/A failed with 2020-11-24 12:41:21 WARNING (MainThread) [homeassistant.helpers.entity] Update of sensor.vp_fremloeb is taking over 10 seconds 2020-11-24 12:41:21 ERROR (MainThread) [homeassistant.components.rest.data] Error fetching data: http://192.168.1.100/A failed with

I hope this request complies the the rules

Best Regards Mogens Bøgh Mortensen

probot-home-assistant[bot] commented 3 years ago

rest documentation rest source (message by IssueLinks)

mogensboegh commented 3 years ago

Thank you probot_home-assistant You do point me to the documentation which i have read But can i ask you to give a hint of how my sensors do not comply ? I have tried to change the sensors so they use recource_template in stead of just resource That gives same result: as soon as i add rest sensor number 5 one or the other of the 5 become unavailable Best regards Mogens

tiagofreire-pt commented 3 years ago

Probably related to https://github.com/home-assistant/core/issues/44023.

mogensboegh commented 3 years ago

Thank you for your comment tiagofreire-pt The fact that only 4 sensors will work as i experience it is also described by GreJ0 24 days ago in #42608 Is there any chance someone will look at this problem since we are stuck with 116.4 ? I know you guys work voluntarily so i am not trying to rush anything I just wish i knew if i am actually stuck. Then i will have to accept this and stop trying to upgrade. Anyway the 116.4 works.

tiagofreire-pt commented 3 years ago

Since these recurrent issues are not probably to be solved in a near future, I found a workaround to this issue: implementing the rest sensor not through yaml but with Node-RED into the Home Assistant (trigger+ http request+ entity node)

imagem

Needs this custom component: https://github.com/zachowj/hass-node-red

It's easy and works flawlessly.

mogensboegh commented 3 years ago

Thank you tiagofreire-pt I really appreciate your answer. Nice to have a workaround. I will give it a try Maybe it will bring me back to follow the upgrades.

mkanet commented 3 years ago

Does anyone know how close we are to fixing Home Assistant? I really don't like the idea of being forced to install and configure an extra addon to my setup; especially since I have no other use for it. I already spent a long time getting all my rest sensors working via Home Assistant.

github-actions[bot] commented 3 years ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

mogensboegh commented 3 years ago

In fact this issue is not solved either in core-2021.3.4 As a last attempt to find a workaround I have implemented a ESP8266 that does all the "rest sensor" curl activity so HA is freed from these. This ESP8266 then publishes the collected results through my mosquitto MQTT broker. It works but adds yet another hardware component to my installation which ought not be necessary. Any hardware component with dedicated software represents a potential source of errors. 😒

rpitera commented 3 years ago

Been moving my REST calls to Node Red as per @tiagofreire-pt and while it's helped with my REST issues, I am also having issues with generic based URL cameras, such as ones for radar/weather conditions as well as those that make a REST call to get a snapshot (e.g. getting a snap from a tablet cam via Fully Kiosk). When the existing HA REST sensors start to fail on me, so do these types of cameras. It's making me wonder if the issue isn't REST but the http/https calls. It doesn't matter whether these calls are internal or external to my network. Even after these fail, I can still ping or do an nslookup from the HA console so I know there isn't a network/DNS issue involved. I've tried debugging aiohttp but see nothing there.

Hope this info helps someone figure out what's going on; I've had a stable HA for years and then all of a sudden a few months ago this started happening. When I moved over my first REST call from HA to NR, it stayed stable for a whole day and I thought maybe I had it fixed so I started moving more over. But now it seems to be happening even sooner after restarts of HA.

It's really getting frustrating. I even built a new VM in Virtualbox and restored my snapshot to it thinking there might be some corruption in the core but it's still there.

System Health

version core-2021.3.4
installation_type Home Assistant OS
dev false
hassio true
docker true
virtualenv false
python_version 3.8.7
os_name Linux
os_version 5.4.99
arch x86_64
timezone America/New_York
Home Assistant Community Store GitHub API | ok -- | -- Github API Calls Remaining | 4429 Installed Version | 1.11.3 Stage | running Available Repositories | 779 Installed Repositories | 54
AccuWeather can_reach_server | ok -- | -- remaining_requests | 49
Home Assistant Cloud logged_in | true -- | -- subscription_expiration | April 16, 2021, 8:00 PM relayer_connected | true remote_enabled | true remote_connected | true alexa_enabled | true google_enabled | true can_reach_cert_server | ok can_reach_cloud_auth | ok can_reach_cloud | ok
Hass.io host_os | Home Assistant OS 5.12 -- | -- update_channel | stable supervisor_version | supervisor-2021.03.6 docker_version | 19.03.13 disk_total | 30.8 GB disk_used | 21.6 GB healthy | true supported | true board | ova supervisor_api | ok version_api | ok installed_addons | Terminal & SSH (9.1.0), ADB - Android Debug Bridge (0.7.0), ESPHome (1.16.2), Visual Studio Code (3.3.0), Let's Encrypt (4.11.0), Node-RED (8.2.1), Home Assistant Google Drive Backup (0.103.1), MariaDB (2.2.2), Check Home Assistant configuration (3.6.0), Glances (0.11.2), Bitwarden RS (0.9.0), Portainer (1.4.0), Tautulli (2.0.5), phpMyAdmin (0.2.0), ozwcp (1.1.2), php-nginx Docker Image (latest), Eufy Home Assistant MQTT Bridge (1.13.0), ioBroker (0.8.0), rest980 Docker Image (20200205)
Lovelace dashboards | 2 -- | -- resources | 45 views | 28 mode | storage
mkanet commented 3 years ago

In my case, the cause was a change made to the REST integration; changing sensor timing from parallel processing to "unlimited" asynch requests. Since these REST requests switched to unlimited, it overloaded my API server; causing my REST sensors to timeout/become unavailable. I was able to eventually use a less resource-intensive solution that didn't overload my API server. Since you have several different API endpoints, it sounds like there's something else going on with your REST sensors than mine; even though they share the same symptom.

Do your REST sensor issues go away when you use the below workaround with the latest Home Assistant? That should let you use the latest Home Assistant with the older REST integration (as if you're still using Home Assistant 0.116.4).

I wish I knew more to help you. Maybe a developer here might know what changed to cause the issue you're seeing.

mogensboegh commented 3 years ago

Thank you mkanet I actually use 2021.3.4 thanks to my workaround I have resigned definitively to solve the problem myself So my residual rest problems get solved by implementing the mqtt workaround all over I prefer this instead of using old 116.4 elements. I am sure this will backfire sooner or later. Tank you for caring

rpitera commented 3 years ago

@mkanet - Wow, thanks for the information - especially the test links! Right now, I have been testing the PR in #47852 and it's solved my generic camera issues so far, with the added bonus of seeming to solve the remaining 4-5 REST sensors I left in HA (everything else moved to nodered for the moment) failing. I've been at 16 hours uptime with everything working nominally.

I'll test out the code you pointed me to after I'm done with the generic cam stuff and let you know how I make out. Thanks for the help!

CarlosGS commented 3 years ago

Let's figure out a repeatable test. I've configured this REST example from the documentation:

sensor:
  - platform: rest
    resource: http://ip.jsontest.com
    name: External IP
    value_template: "{{ value_json.ip }}"

It doesn't work. Extract from the log:

2021-04-15 23:35:29 WARNING (MainThread) [homeassistant.components.sensor] Setup of sensor platform rest is taking over 10 seconds.
2021-04-15 23:35:29 ERROR (MainThread) [homeassistant.components.rest.data] Error fetching data: http://ip.jsontest.com failed with 
2021-04-15 23:35:29 WARNING (MainThread) [homeassistant.components.sensor] Platform rest not ready yet. Retrying in 30 seconds.
2021-04-15 23:35:49 ERROR (MainThread) [homeassistant.components.updater] Timeout fetching Home Assistant update data
2021-04-15 23:36:09 WARNING (MainThread) [homeassistant.components.sensor] Setup of sensor platform rest is taking over 10 seconds.
2021-04-15 23:36:09 ERROR (MainThread) [homeassistant.components.rest.data] Error fetching data: http://ip.jsontest.com failed with 
2021-04-15 23:36:09 WARNING (MainThread) [homeassistant.components.sensor] Platform rest not ready yet. Retrying in 60 seconds.

Version: core-2021.4.4

github-actions[bot] commented 3 years ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.