Rest integration "Error fetching data" if the device is off


I am using a rest integration to get some datas from a Water Boiler and when this device it is off, I only get errors in the log, similar to Error fetching data: failed with All connection attempts failed.

I don’t know if is possible and this is why I ask here… there is any possibility to make this sensor somehow to know when the device is off or on?

I have even added a very big scan_interval, and I only fetch data “manually” from an automation, only when the device is off… but I see it does not count. Here is what I have done till now:

- authentication: basic
  scan_interval: 1576800000
    - name: "Bathroom Water Boiler"
      icon: mdi:water-boiler
      value_template: "OK"
        - "tmpT"
        - "bst"
        - "pwr"
        - "err"
        - "cdt"

And this is the automation, which for another similar sensor, made with scrape integration, it is working very well… But here, with rest… nothing good

alias: Auto - Bathroom Water Boiler Update Sensor (every 3 seconds, if boiler on)
description: ""
  - platform: time_pattern
    seconds: /3
  - condition: state
    entity_id: switch.sonoff_bathroom_boiler_pow
    state: "on"
  - service: homeassistant.update_entity
    data: {}
      entity_id: sensor.bathroom_water_boiler
mode: single

Any idea? Thanks!

That’s a good idea. What do you mean by “it does not count”, i.e. what is (not) happening?

I mean that even if you put a very big scan_interval, the rest will still try to get the information from the url.
Even with this big scan interval, I still get errors of fetching data, when the device is off

That’s the first time after a HA restart/reboot, you indeed cannot prevent this.
But it’s one time, vs. every minute or so…

I think it is not only when HA restarts, look: First occurred: July 11, 2023 at 23:14:34 (2842 occurrences)
So… from yesterday till now, 2842 erros :smiley:

This is why I don’t understand why REST is doing this. SCRAPE sensor it is not updating even if you restart HA, which works great, but I don’t know if I can or if is possible to make a similar sensor with SCRAPE instead REST… :frowning:

Are you sure your automation condition works? Because it is trying every 3 seconds :wink:

Yes, because the automation should meet a condition, which can’t pass through if the device it is not ON.
Take a look, the automation last run was yesterday (when I made some tests)

I have disabled the automation right now, only to test it, to be 100% sure that the automation don’t do something which I can’t see… :smiley:

I reconfirm it, the automation it is working how it should, the REST is the problem…
Even with the automation disabled, I still get those errors… :frowning:

Seems that REST does not care about the “scan_interval”

Could you show the actual errors from the log, please.
Sure you don’t have multiple REST sensors?

Only one

Source: components/rest/
Integration: RESTful ([documentation](, [issues](
First occurred: 11:53:42 (12 occurrences)
Last logged: 12:27:09

Error fetching data: failed with All connection attempts failed

I’m clueless.

12 occurrences from 11:53 to 12:27 looks like about once every 3 minutes. Default scan interval is 30 seconds, so there must be something else doing those calls :wink:

Yes, but I don’t know what it is happening… I don’t have anything else inside HA, regarding REST integration… This is because i try to use it from few days ago…

I think I solved it… No errors till now

Seems that RESTful integration, does not care about scan_interval… it will check the resource no matter what, but RESTful Sensor integration, in the other hand, have the scan_interval working good…

So I changed to this:

- platform: rest
  authentication: basic
  scan_interval: 1576800000
  name: "Bathroom Water Boiler"
  timeout: 120
  icon: mdi:water-boiler
  value_template: "OK"
    - "tmpT"
    - "bst"
    - "pwr"
    - "err"
    - "cdt"

FWIW, I did a test and the Restful integration works exactly as expected :wink:

RESTfull maybe yes, but “scan_interval”, for me and for another friend, with the same device, it is not working well… RESTfull sensor instead, it is perfect for this. :frowning: I don’t understand why and how, I saw more people complaining about this REST, talking about the fact that this is a very old integration which didn’t have more support or something like this. I don’t know details, it is what I found on the internet