Cannot get rest to work


yes, in a package

That will work

The first one doesn’t because the interior double quote isn’t escaped

1 Like

How is it supposed to be?

See the post I replied to. That code will work.

But it is not, Home-Assistant says “Configuration Invalid”

Because you still haven’t used it. Your “proof of trying it posts” show you using the previous one provided by Tom. His latest will work.

Edit: I’m on mobile and having trouble quoting.

This from Tom

value_template: >
  {{ value|replace('"','') }}

Sorry - I did not see the message of tom sorry. Thank you for help.

@tom_l
@petro

sorry - And thanks for the help.

So like this?

value_template: "{{ value|replace('\"','') }}"

I remember that single quotes are escaped with single quotes but double quotes use the backslash, yes?

Yeah. That should work.

\ will work for escaping any character typically. Admittedly, I don’t have it memorized for jinja, but it should work similar to python.

1 Like

You do realise ha has a glances integration, rendering all this unnecessary?

There is no everything - the operating time of the server, one example.

Yes I see that now. Maybe a feature request?

# curl http://localhost:61208/api/3/sensors/label/acpitz 1
{'acpitz 1': [{'critical': 105,
               'key': 'label',
               'label': 'acpitz 1',
               'type': 'temperature_core',
               'unit': 'C',
               'value': 27,
               'warning': 105}]}

my code:

  - platform: rest
    name: "Pi-4 Sensors"
    resource: http://192.168.1.244:61208/api/3/sensors
    value_template: "{{ value_json.unit }}"
    unit_of_measurement: "C"

I do not think it’s true - so asking for help. I’m not a programmer

That is not valid json. This is:

{"acpitz 1": [{"critical": 105,
               "key": "label",
               "label": "acpitz 1",
               "type": "temperature_core",
               "unit": "C",
               "value": 27,
               "warning": 105}]}

Did you copy it correctly?

https://glances.readthedocs.io/en/latest/api.html#get-sensors

I copied a … Apparently I did not copy true.

When you open this http://192.168.1.244:61208/api/3/sensors in a web browser what do you see?

pi@pihole-master:~ $ sensors
cpu_thermal-virtual-0
Adapter: Virtual device
temp1:        +44.3°C