Json string for rest api for the Shelly 1PM temperature sensor ad-on

Good morning,

I have a question about the shelly integration with the rest api (not Mqtt) with Home assistant.

I have everything running for 99% i have only one problem, and that is to get the temperature readings
from a shelly 1PM with the Temperature Add on with a DS18B20 sensor. integrated in Home Assist.

The switch relay itself is working fine, but i have tried a whole day to get the temperature reading working.

In the configuration.yalm file i’m using the following commands for the temperature add on:

sensor:

  • platform: rest
    name: “1PM Temperatuur”
    scan_interval: 5
    resource: http://10.10.1.11/status
    value_template: ‘{{ value_json.ext_sensors[“ext_sensors”]}}’

I googled and searched lot of sites to get the correct json value , but i didn’t find anything related for the temperature add-on.

I hope there is someone on this community who already have a working configuration based on the rest api.

if you see the screenshot below you can see the switch button is working, only the temperature value stays blank, but this is because i don’t have the correct value template…

SNAG-0342

Leave the value template empty, then have a play around with it in Developer Tools / Template until you find what works

Hi Jivesinger,

I deleted everything behind the “value template” so it is empty, but if i then do a restart of HA i get a error message and HA doesn’t restart.

I’m new to HA and never did something with the developer tools, but need the “value template” realy be empty if i wan’t to test with the developer tools?

Sorry, I should have been more specific.

value_template: ‘{{ value_json }}'

Thank you for the update, i’m going to try this.

Can you post the output when you put

http://10.10.1.11/status

Into your web browser ?

Good morning Jivesinger,

See the output below, dont look to the IP adres of the Shelly because i have changed it to a other subnet, this i have already changed in the configuration file also, and the plug is reachable.

{“wifi_sta”:{“connected”:true,“ssid”:“Urban2-DM”,“ip”:“10.10.2.11”,“rssi”:-89},“cloud”:{“enabled”:true,“connected”:true},“mqtt”:{“connected”:false},“time”:“09:04”,“unixtime”:1598087053,“serial”:1742,“has_update”:false,“mac”:“D8BFC019C2FE”,“cfg_changed_cnt”:4,“actions_stats”:{“skipped”:0},“relays”:[{“ison”:true,“has_timer”:false,“timer_started”:0,“timer_duration”:0,“timer_remaining”:0,“overpower”:false,“source”:“cloud”}],“meters”:[{“power”:18.46,“overpower”:0.00,“is_valid”:true,“timestamp”:1598087053,“counters”:[18.414, 18.375, 18.388],“total”:27473}],“inputs”:[{“input”:0,“event”:"",“event_cnt”:0}],“ext_sensors”:{“temperature_unit”:“C”},“ext_temperature”:{“0”:{“hwID”:“28935946321901e8”,“tC”:21.31,“tF”:70.36}},“ext_humidity”:{},“temperature”:50.74,“overtemperature”:false,“tmp”:{“tC”:50.74,“tF”:123.34, “is_valid”:true},“update”:{“status”:“idle”,“has_update”:false,“new_version”:“20200812-092009/v1.8.0@8acf41b0”,“old_version”:“20200812-092009/v1.8.0@8acf41b0”},“ram_total”:50712,“ram_free”:37444,“fs_size”:233681,“fs_free”:148090,“uptime”:90036}

also a screenshot from the output below:

I know it have something to do with the following line:

“ext_sensors”:{“temperature_unit”:“C”},“ext_temperature”:{“0”:{“hwID”:“28935946321901e8”,“tC”:21.31,“tF”:70.36}},“

But i’m not able to create a correct string in the configuration file so the temperature will show…

value_template: ‘{{ value_json.ext_temperature['0']['tC']}}’

Good morning Jivesinger,

Thank you, it works now with the given value!!

Kind regards,

Jarno

Hi.
Can you please put here the complete link to get the temperatura addon?
Thanks.

will be greate for me to, its not working

mqtt:
sensor:
- name: “Temperature0”
state_topic: shellies/shelly1pm-441793A74B14/ext_temperature/100
suggested_display_precision: 1
unit_of_measurement: “°C”
value_template: ‘{{ value_json.ext_temperature[‘100’][‘tC’]}}’

Why are you using ['100']?!

It shows addres 100 for first externel sensor
temperature:100 = {“id”: 100,“tC”:20.6, “tF”:69.0}
101 … etc.

It shows addres 100 for first externel sensor
temperature:100 = {“id”: 100,“tC”:20.6, “tF”:69.0}
101 … etc.

I have to use this code
Sensor:

  • platform: rest
    resource: http://shelly_ip/rpc/shelly.getstatus
    unit_of_measurement: “C”
    method: GET
    scan_interval: 30
    name: shelly_Temp
    value_template: “{{ value_json[‘temperature:100’][‘tC’] }}”
    force_update: true