Cannot get rest-platform to work

Hello together,

first off I hope I opened this topic in the correct category. If not, please let me know.

I started tinkering with home assistant about a week ago and love it so far. Everything is very intuitive and easy to manage.

But there’s one thing I can’t get to work: a REST sensor.
I don’t get any error, the log just gets flooded with
WARNING (MainThread) [homeassistant.components.sensor] Setup of sensor platform rest is taking over 10 seconds.
every 3 minutes or so.
The sensors do not show up as entities.

My sensor looks like this:

- platform: rest
  name: "Outside Temp"
  scan_interval: 60
  resource: http://192.168.110.1:8080/user/var//120/10601/0/0/12197
  value_template: '{{ value_json.eta.value["@strValue"] | replace(",", ".") | float }}'
  unit_of_measurement: "°C"
  force_update: true

All my sensors are in their own config file sensors.yaml and are called in the configuration.yaml via
sensor: !include sensors.yaml

I already tried the following things:

  • put whole sensor into configuration.yaml
  • enabled/disabled force update
  • rebootet the whole docker in case something got stuck

Does any of you have an idea where I could look for further troubleshooting?

*Edit:
I am on version core-2021.8.8

What do you get with:

- platform: rest
  name: "Outside Test"
  resource: http://192.168.110.1:8080/user/var//120/10601/0/0/12197
  value_template: '{{ value }}'

Thanks a lot for your quick reply!

Unfortunately it does look exactly the same.
If the sensor is working correctly it should show up as an entity sensor.outside_test, right?

2021-08-23 12:37:11 WARNING (MainThread) [homeassistant.components.sensor] Setup of sensor platform rest is taking over 10 seconds.
2021-08-23 12:37:11 WARNING (MainThread) [homeassistant.components.sensor] Platform rest not ready yet; Retrying in background in 30 seconds
2021-08-23 12:37:21 WARNING (MainThread) [homeassistant.components.sensor] Setup of sensor platform rest is taking over 10 seconds.
2021-08-23 12:38:31 WARNING (MainThread) [homeassistant.components.sensor] Setup of sensor platform rest is taking over 10 seconds.
2021-08-23 12:40:11 WARNING (MainThread) [homeassistant.components.sensor] Setup of sensor platform rest is taking over 10 seconds.

What do you get when you put this in the browser?
http://192.168.110.1:8080/user/var//120/10601/0/0/12197

I find the two last octets suspicious.
Are you sure it’s not supposed to be …1.110?

That’s working just fine.

<eta xmlns="http://www.eta.co.at/rest/v1" version="1.0">
<value uri="/user/var//120/10601/0/0/12197" strValue="19,7" unit="°C" decPlaces="1" scaleFactor="10" advTextOffset="0">197</value>
</eta>

The IP is correct. It’s a very tiny DMZ :slight_smile:

What’s strange is that in my firewall I don’t see any traffic from my home assistant docker to this device. When I wget the URL from my home assistant docker I see traffic.

Did a search and this looks very similar.

Yep. The restful sensor converts XML to JSON automatically and puts an @ symbol in front of every attribute.

This is a worry though:

Oh, also you can’t use the key value in your template unless you use square bracket format as it has a special meaning in the rest value template. You have to do this:

'{{ value_json.eta.["value"]["@strValue"] | replace(",", ".") | float }}'

@Hellis81 it does look very similiar, yes.
Unfortunately the issue has been resolved by updating to 0.107
I will check the debug logs later today, that sound’s like a viable strategy :slight_smile:

@tom_l : when I edit the value like you suggested I get an error when checking the configuration:

Invalid config for [sensor.rest]: 
invalid template (TemplateSyntaxError: expected name or number) for dictionary value @ data['value_template']. 
Got '{{ value_json.eta.["value"]["@strValue"] | replace(",", ".") | float }}'. (See ?, line ?).

Remove the period after eta

'{{ value_json.eta.["value"]["@strValue"] | replace(",", ".") | float }}'
                  ^
                  |
          Remove this period
1 Like

:question:

That’s not an update. That’s a downgrade.

Apologies for the errant .

He’s reading the accepted answer of the thread I linked to.
That is obviously not what I was suggesting, but to actually look at the config posted in the thread…

1 Like

Gotcha. That will also require an @ in front of value and eta

'{{ value_json["@eta"]["@value"]["@strValue"] | replace(",", ".") | float }}'
1 Like

Thanks a lot guys.

I really appreciate your patience!

I don’t think the issue you linked @Hellis81 is the same I have.
I had a look at the debug logs and the only thing regarding homeassistant.components.rest.dataI can find is the following:

2021-08-23 16:23:40 DEBUG (MainThread) [homeassistant.components.rest.data] Updating from http://192.168.110.1:8080/user/var//120/10601/0/0/12197

In the other thread an Erroneous JSON was quoted, which would make sense. But here it seems to be doing absolutely nothing?

See what this returns.

- platform: rest
  name: "Outside Test"
  resource: http://192.168.110.1:8080/user/var//120/10601/0/0/12197
  value_template: '{{ value_json }}'

Are you 100% sure when you visited that resource in your web browser (and it worked) that the browser did not change the URL to https?

I tried your suggestion @tom_l
I am not sure if that’s new or if I just didn’t see it earlier, but now I see a “setting up sensor rest” from time to time in the debug logs.

2021-08-23 17:00:46 INFO (MainThread) [homeassistant.components.sensor] Setting up sensor.rest
2021-08-23 17:00:46 DEBUG (MainThread) [homeassistant.components.rest.data] Updating from http://192.168.110.1:8080/user/var//120/10601/0/0/12197
2021-08-23 17:00:46 INFO (MainThread) [homeassistant.components.sensor] Setting up sensor.rest
2021-08-23 17:00:46 DEBUG (MainThread) [homeassistant.components.rest.data] Updating from http://192.168.110.1:8080/user/var//120/10601/0/0/12197

I am 100% sure there was no redirect to https. I can call the API without any issues via curl.

curl http://192.168.110.1:8080/user/var//120/10601/0/0/1291
   <?xml version="1.0" encoding="utf-8"?>
   <eta version="1.0" xmlns="http://www.eta.co.at/rest/v1">
     <error>Invalid permission</error>
   </eta>

Maybe I am understanding something substantially wrong - the sensors should show up under my entities, right?

You should see it in Developer Tools / States and in Configuration / Entities.

This:

- platform: rest
  name: "Outside Test"
  resource: http://192.168.110.1:8080/user/var//120/10601/0/0/12197
  value_template: '{{ value_json }}'

Should have created an entity called sensor.outside_test

Thank you for the clarification. There has no entity been created.

You restarted home assistant after creating the rest sensor?

Yes i restarted via server controls after every change.
Just for good measure I powercycled the whole system just now, nothing changed

Just a quick update:
The initial value_template was correct.
I’ve just looked at what xmltodict should output and threw that into the template dev tool.

{% set value_json =
{"eta":{"@version":"1.0","@xmlns":"http://www.eta.co.at/rest/v1","value":{"#text":"152","@advTextOffset":"0","@decPlaces":"1","@scaleFactor":"10","@strValue":"15,2","@unit":"\u00b0C","@uri":"/user/var//120/10601/0/0/12197"}}}
%}
value_template: '{{ value_json.eta.value["@strValue"] | replace(",", ".") | float }}'

This outputs result type: string
value_template: '15.2'

I am starting to suspect either a network issue or somehow the api does not get called at all.
Even if the value template was wrong I should get an entity, even if the values are off, right?

Is it somehow possible to reinstall the api client?