Like this:
Would possibly also work to use a RestFul command but that will end up as an service that you then need to handle:
Like this:
Would possibly also work to use a RestFul command but that will end up as an service that you then need to handle:
Thanks for this post! It really helped a lot!
Thanks to everyone else who contributed as well.
I can now control a shelly device that is NOT on the same network as the Home Assitant instance, and receive status updates from the shelly.
Great use cases are:
NB: Always beware of the security risks of putting access control onto a cloud system. If you don’t understand them, don’t do it.
Can anyone give me some help?
I’m trying to get the voltage from a Plus Uni
rest:
- resource: https://shelly-77-eu.shelly.cloud/device/status
method: POST
payload: 'auth_key=123456789abcdefg&id=AAAAAAAAAAA'
headers:
User-Agent: Home Assistant
Content-Type: application/x-www-form-urlencoded
scan_interval: 5
sensor:
- name: "Caddy Battery (Cloud API) - Voltage"
value_template: '{{ value_json.data.device_status.voltmeter.100.voltage }}'
device_class: voltage
unit_of_measurement: 'V'
Im sure my value_template is wrong
With recent HA updates this is broken now… not sure how to resolve.
Logger: homeassistant.helpers.template
Source: helpers/template.py:2652
First occurred: 09:41:21 (21 occurrences)
Last logged: 09:51:21
Template variable error: dict object has no element 0 when rendering '{{ value_json.data.device_status.ext_temperature[0].tC }}'
I used to be able to get reading with this, but it is not working anymore…
- platform: rest
name: "Solar Battery"
device_class: voltage
unique_id: solar_battery_id
resource: "https://shelly-31-eu.shelly.cloud/device/status?id=12345678&auth_key=12345678"
method: POST
value_template: "{{ value_json.data.device_status.adcs[0].voltage }}"
unit_of_measurement: "V"
actualy it works, but it is not updating.
Temperature is not working…
{{ value_json.data.device_status.ext_temperature[0].tC }}
Looks like shelly output is different now… Voltage works now, i found that shelly cloud server changed, now updated yaml. Temperature is still not working.
{
"isok": true,
"data": {
"online": false,
"device_status": {
"mqtt": {
"connected": false
},
"wifi_sta": {
"connected": true,
"ssid": "GEO",
"ip": "192.168.55.51",
"rssi": -23
},
"actions_stats": {
"skipped": 0
},
"time": "16:22",
"ext_sensors": {
"temperature_unit": "C"
},
"getinfo": {
"fw_info": {
"device": "shellyuni-12345678",
"fw": "20230913-114521/v1.14.0-gcb84623"
}
},
"update": {
"status": "idle",
"has_update": false,
"new_version": "20230913-114521/v1.14.0-gcb84623",
"old_version": "20230913-114521/v1.14.0-gcb84623",
"beta_version": "20231107-165239/v1.14.1-rc1-g0617c15"
},
"uptime": 495321,
"unixtime": 1717082012,
"ram_total": 50776,
"fs_size": 233681,
"ext_temperature": {
"0": {
"hwID": "12345678",
"tC": 15.31,
"tF": 59.56
}
},
"ext_humidity": {},
"inputs": [
{
"input": 0,
"event": "",
"event_cnt": 0
},
{
"input": 0,
"event": "",
"event_cnt": 0
}
],
"serial": 49980,
"has_update": false,
"mac": "12345678",
"cloud": {
"enabled": true,
"connected": true
},
"ram_free": 39088,
"relays": [
{
"ison": false,
"has_timer": false,
"timer_started": 0,
"timer_duration": 0,
"timer_remaining": 0,
"source": "input"
},
{
"ison": false,
"has_timer": false,
"timer_started": 0,
"timer_duration": 0,
"timer_remaining": 0,
"source": "input"
}
],
"adcs": [
{
"voltage": 14.29
}
],
"fs_free": 147086,
"_updated": "2024-05-30 15:22:01",
"cfg_changed_cnt": 0
}
}
}
so now need to get reading from:
"ext_temperature": {
"0": {
"hwID": "12345678",
"tC": 22.12,
"tF": 71.83
}
},
Is there a solution to this?
Interestingly, the switch (relays) works, but the temperature (ext_temperature) does not.
Template variable error: dict object has no element 0 when rendering ‘{{ value_json.data.device_status.ext_temperature[0].tC | round(1) }}’
You probably need to make it ["0"]
Hi,
I tried all the suggestions what you’ve all posted here, but nothing works.
I have a Shelly Plus Uni and want to see the Voltage in HASS.
Here is the code:
sensor:
- platform: rest
name: "Trabant Garage Batterie"
device_class: Battery
unique_id: trabant_garage_batterie
resource: 'https://shelly-118-eu.shelly.cloud/device/status?id=123456&auth_key=ABCDEFG'
method: POST
value_template: '{{ value_json.data.device_status.adcs[0].voltage }}'
unit_of_measurement: 'V'
When I add the complete ressource string to the address bar in the browser I see the data, this is working.
In HASS I get this:
I would be glad if someone can help me to solve this.
Many thanks in advance
Has no one an answer how to solve this?
It still will not work and I don’t understand why.
Is there anything further to do in HASS to activate REST or something?
Did you try what I posted just above your comment?
Yes, but still not working.
I tried all solutions in this article before I raised my comment.
Do you have any other idea?
I have this in my configuration.yaml
- platform: rest
name: front_water_tank_rest2
unit_of_measurement: "v"
resource: https://shelly-76-eu.shelly.cloud/device/status
method: POST
payload: auth_key=insert your key&id=insert your id
scan_interval: 30
headers:
User-Agent: Home Assistant
Content-Type: application/x-www-form-urlencoded
value_template: "{{ value_json.data.device_status.adcs[0].voltage | default('N/A') }}"
This creates a sensor called sensor.front_water_tank_rest2 and returns the voltage. I have cloud enabled on the device.