template:
- sensor:
- name: "hvac_0_combined"
state: "{{ state_attr('sensor.HVAC_0','Result')['Point'][1]['Value'] }}"
attributes:
ctr_type: "{{ state_attr('sensor.HVAC_0','Result')['Point'][0]['Value'] }}"
runstate: "{{ state_attr('sensor.HVAC_0','Result')['Point'][1]['Value'] }}"
chil_s_s: "{{ state_attr('sensor.HVAC_0','Result')['Point'][2]['Value'] }}"
etc - to create a single sensor as @Hellis81 has suggested.
nitinuae
(Nitinuae)
August 29, 2022, 11:57am
22
Will something like this work (As I said - I dont know the basics of json)- Trial and error
scan_interval: 5
resource: http://192.168.39.14/app/config/0/0
sensor:
- name: "HVAC_0"
value_template: "OK"
json_attributes:
- "Result"
resource: http://192.168.39.14/app/config/0/1
sensor:
- name: "HVAC_1"
value_template: "OK"
json_attributes:
- "Result"
template:
- sensor:
- name: "ctr_type"
state: "{{ state_attr('sensor.HVAC_0','Result')['Point'][0]['Value'] }}"
- name: "runstate"
state: "{{ state_attr('sensor.HVAC_0','Result')['Point'][1]['Value'] }}"
and son on (notice that I am pulling each page as HVAC_0 and HVAC_1 etc
Hellis81
(Hellis81)
August 29, 2022, 12:01pm
23
Something is missing.
Is this supposed to be a RESTful Sensor - Home Assistant (home-assistant.io) or RESTful - Home Assistant (home-assistant.io) ?
What you posted will not work. But we need to know which route you are trying to use now.
Yes that looks fine.
One quick note - ALL sensor names are lowercase in Home Assistant - so it would be:
state_attr('sensor.hvac_0','Result')['Point'][0]['Value']
I should have noticed in my previous examples.
Hellis81
(Hellis81)
August 29, 2022, 12:03pm
25
mobile.andrew.jones:
Yes that looks fine.
No it doesnât.
There are duplicate resource
and sensor
.
There should be -
somewhere but it depends on the route he is trying now.
I assumed it was just a copy and paste issue - because he had the correct format in the first post. (Resource had a -
)
rest:
- authentication: basic
username: "xx"
password: "xx"
scan_interval: 2
resource: http://192.168.39.14/app/config/0/0
sensor:
- name: "HVAC_0"
value: "OK"
json_attributes:
- "Result"
- authentication: basic
username: "xx"
password: "xx"
scan_interval: 2
resource: http://192.168.39.14/app/config/0/1
sensor:
- name: "HVAC_1"
value: "OK"
json_attributes:
- "Result"
(Personally I wouldnât drop the scan interval any lower than 10 seconds though⌠ask yourself if you really need updates every 2 seconds? Aside from the huge amount of data that will add to the database - itâs going to be making Home Assistant pretty busy)
1 Like
nitinuae
(Nitinuae)
August 29, 2022, 12:09pm
27
Yes - Its retsful sensor.
There is only a small page in HA help pages and that too is incomplete. It doesnot show the original jason , and just gives the example without reference. Thats why the confusion.
If you read my jason results above - You will get what I want.
Andrew Jones walked me through it but I was misled by post from Dec21 that it was a single jason request,
petro
(Petro)
August 29, 2022, 2:15pm
28
This is wrong. The resource is called once for each configuration in the rest integration and the data is passed to each sensor listed in the sensor section. This comment lead to @nitinuae opening old threads to spread more miss-information.
He could have 1 rest call with all his sensors with the following configuration. Notice the rest resource is different (removed last index) and the addition of json_attributes_path.
rest:
- authentication: basic
username: "xx"
password: "xx"
scan_interval: 2
resource: http://192.168.39.14/app/config/0
sensor:
- name: "HVAC_0"
value: "OK"
json_attributes_path: $.0
json_attributes:
- "Result"
- name: "HVAC_1"
value: "OK"
json_attributes_path: $.1
json_attributes:
- "Result"
To further clarify, the rest integration is 1 resource call â update multiple sensors. The rest sensor platform is 1 resource call â update 1 sensor.
nitinuae
(Nitinuae)
August 29, 2022, 4:41pm
29
Oops - I did open old thread - and In fact I hit another rate limitation helper thread (I hit rate limitation INSIDE of HA).
I will now try what you have written above and report.
nitinuae
(Nitinuae)
August 29, 2022, 4:58pm
30
Its not allowing me to restart.
Invalid config for [rest]: [value] is an invalid option for [rest]. Check: rest->rest->0->sensor->0->value. (See ?, line ?).
CHECK CONFIGURATIONRESTART
Here is my full file -
rest:
- authentication: basic
username: "xx"
password: "xx"
scan_interval: 7
resource: http://192.168.39.14/app/config/0/0
sensor:
- name: "hvac_0"
value: "OK"
json_attributes_path: $.0
json_attributes:
- "Result"
- authentication: basic
username: "xx"
password: "xx"
scan_interval: 8
resource: http://192.168.39.14/app/config/0/1
sensor:
- name: "hvac_1"
value: "OK"
json_attributes_path: $.0
json_attributes:
- "Result"
- authentication: basic
username: "xx"
password: "xx"
scan_interval: 9
resource: http://192.168.39.14/app/config/0/2
sensor:
- name: "hvac_2"
value: "OK"
json_attributes_path: $.0
json_attributes:
- "Result"
- authentication: basic
username: "xx"
password: "xx"
scan_interval: 10
resource: http://192.168.39.14/app/config/0/3
sensor:
- name: "hvac_3"
value: "OK"
json_attributes_path: $.0
json_attributes:
- "Result"
- authentication: basic
username: "xx"
password: "xx"
scan_interval: 11
resource: http://192.168.39.14/app/config/0/4
sensor:
- name: "hvac_4"
value: "OK"
json_attributes_path: $.0
json_attributes:
- "Result"
- authentication: basic
username: "xx"
password: "xx"
scan_interval: 6
resource: http://192.168.39.14/app/config/0/5
sensor:
- name: "hvac_5"
value: "OK"
json_attributes_path: $.0
json_attributes:
- "Result"
template:
- sensor:
- name: "ctr_type"
state: "{{ state_attr('sensor.hvac_0','Result')['Point'][0]['Value'] }}"
- name: "runstate"
state: "{{ state_attr('sensor.hvac_0','Result')['Point'][1]['Value'] }}"
- name: "CHIL_S_S"
state: "{{ state_attr('sensor.hvac_0','Result')['Point'][2]['Value'] }}"
- name: "CHIL_OCC"
state: "{{ state_attr('sensor.hvac_0','Result')['Point'][3]['Value'] }}"
- name: "min_left"
state: "{{ state_attr('sensor.hvac_0','Result')['Point'][4]['Value'] }}"
- name: "ALM"
state: "{{ state_attr('sensor.hvac_0','Result')['Point'][7]['Value'] }}"
- name: "CAP_T"
unit_of_measurement: "%"
state: "{{ state_attr('sensor.hvac_0','Result')['Point'][13]['Value'] }}"
- name: "SP"
unit_of_measurement: "°C"
state: "{{ state_attr('sensor.hvac_0','Result')['Point'][17]['Value'] }}"
- name: "CTRL_PNT"
unit_of_measurement: "°C"
state: "{{ state_attr('sensor.hvac_0','Result')['Point'][18]['Value'] }}"
- name: "CTRL_WT"
unit_of_measurement: "°C"
state: "{{ state_attr('sensor.hvac_0','Result')['Point'][19]['Value'] }}"
- name: "OAT"
unit_of_measurement: "°C"
state: "{{ state_attr('sensor.hvac_0','Result')['Point'][20]['Value'] }}"
- name: "CAP_A"
unit_of_measurement: "%"
state: "{{ state_attr('sensor.hvac_1','Result')['Point'][0]['Value'] }}"
- name: "DP_A"
unit_of_measurement: "kPa"
state: "{{ state_attr('sensor.hvac_1','Result')['Point'][2]['Value'] }}"
- name: "SP_A"
unit_of_measurement: "kPa"
state: "{{ state_attr('sensor.hvac_1','Result')['Point'][3]['Value'] }}"
- name: "SCT_A"
unit_of_measurement: "°C"
state: "{{ state_attr('sensor.hvac_1','Result')['Point'][4]['Value'] }}"
- name: "SST_A"
unit_of_measurement: "°C"
state: "{{ state_attr('sensor.hvac_1','Result')['Point'][5]['Value'] }}"
- name: "CP_A1"
state: "{{ state_attr('sensor.hvac_2','Result')['Point'][0]['Value'] }}"
- name: "CP_A2"
state: "{{ state_attr('sensor.hvac_2','Result')['Point'][1]['Value'] }}"
- name: "FAN_A1"
state: "{{ state_attr('sensor.hvac_2','Result')['Point'][3]['Value'] }}"
- name: "CAP_B"
unit_of_measurement: "%"
state: "{{ state_attr('sensor.hvac_3','Result')['Point'][0]['Value'] }}"
- name: "DP_B"
unit_of_measurement: "kPa"
state: "{{ state_attr('sensor.hvac_3','Result')['Point'][2]['Value'] }}"
- name: "SP_B"
unit_of_measurement: "kPa"
state: "{{ state_attr('sensor.hvac_3','Result')['Point'][3]['Value'] }}"
- name: "SCT_B"
unit_of_measurement: "°C"
state: "{{ state_attr('sensor.hvac_3','Result')['Point'][4]['Value'] }}"
- name: "SST_B"
unit_of_measurement: "°C"
state: "{{ state_attr('sensor.hvac_3','Result')['Point'][5]['Value'] }}"
- name: "CP_B1"
state: "{{ state_attr('sensor.hvac_4','Result')['Point'][0]['Value'] }}"
- name: "CP_B2"
state: "{{ state_attr('sensor.hvac_4','Result')['Point'][1]['Value'] }}"
- name: "FAN_B1"
state: "{{ state_attr('sensor.hvac_4','Result')['Point'][3]['Value'] }}"
- name: "EWT"
unit_of_measurement: "°C"
state: "{{ state_attr('sensor.hvac_5','Result')['Point'][0]['Value'] }}"
- name: "LWT"
unit_of_measurement: "°C"
state: "{{ state_attr('sensor.hvac_5','Result')['Point'][1]['Value'] }}"
- name: "reset"
unit_of_measurement: "°C"
state: "{{ state_attr('sensor.hvac_5','Result')['Point'][13]['Value'] }}"
- name: "PUMP_1"
state: "{{ state_attr('sensor.hvac_5','Result')['Point'][18]['Value'] }}"
- name: "PUMP_2"
state: "{{ state_attr('sensor.hvac_5','Result')['Point'][19]['Value'] }}"
nitinuae
(Nitinuae)
August 29, 2022, 5:05pm
31
est:
- authentication: basic
username: "xx"
password: "xx"
scan_interval: 2
resource: http://192.168.39.14/app/config/0
sensor:
- name: "HVAC_0"
value: "OK"
json_attributes_path: $.0
json_attributes:
- "Result"
Should I make value: âOKâ
to
Value_template: âOKâ ?
petro
(Petro)
August 29, 2022, 5:36pm
32
Yeah you keep doing it wrong. This is what it would be
rest:
- authentication: basic
username: "xx"
password: "xx"
scan_interval: 7
resource: http://192.168.39.14/app/config/0
sensor:
- name: "hvac_0"
value_template: "OK"
json_attributes_path: "$.0"
json_attributes:
- "Result"
- name: "hvac_1"
value_template: "OK"
json_attributes_path: "$.1"
json_attributes:
- "Result"
- name: "hvac_2"
value_template: "OK"
json_attributes_path: "$.2"
json_attributes:
- "Result"
- name: "hvac_3"
value_template: "OK"
json_attributes_path: "$.3"
json_attributes:
- "Result"
- name: "hvac_4"
value_template: "OK"
json_attributes_path: "$.4"
json_attributes:
- "Result"
- name: "hvac_5"
value_template: "OK"
json_attributes_path: "$.5"
json_attributes:
- "Result"
Notice I cahnged the resource from
http://192.168.39.14/app/config/0/0
http://192.168.39.14/app/config/0/1
http://192.168.39.14/app/config/0/2
http://192.168.39.14/app/config/0/3
http://192.168.39.14/app/config/0/4
http://192.168.39.14/app/config/0/5
to
http://192.168.39.14/app/config/0
Then the json_attributes_path handles the .0, .1, .2, .3, .4, and .5.
nitinuae
(Nitinuae)
August 29, 2022, 6:12pm
33
I tried verbatim as above. it fails with
Invalid config for [rest]: [value] is an invalid option for [rest]. Check: rest->rest->0->sensor->0->value. (See ?, line ?).
After changing value to value _template, it allows me to reload.reboot, but fails to get any data in sensors. In devtools, stats, hvac_0 remains unknown.
nitinuae
(Nitinuae)
August 29, 2022, 6:32pm
34
Also -elaborating on your photo you posted, how can this be one call?
resource: http://192.168.39.14/app/config/0/0
and
resource: http://192.168.39.14/app/config/0/1
They have to be 2 calls.
Hellis81
(Hellis81)
August 29, 2022, 6:35pm
35
That is exactly what he explained in the previous post
petro:
Notice I cahnged the resource from
http://192.168.39.14/app/config/0/0
http://192.168.39.14/app/config/0/1
http://192.168.39.14/app/config/0/2
http://192.168.39.14/app/config/0/3
http://192.168.39.14/app/config/0/4
http://192.168.39.14/app/config/0/5
to
http://192.168.39.14/app/config/0
Then the json_attributes_path handles the .0, .1, .2, .3, .4, and .5.
petro
(Petro)
August 29, 2022, 6:35pm
36
petro:
value: "OK"
ah yes, I didnât notice that. They should be value_template: "OK"
.
yepâŚ
nitinuae
(Nitinuae)
August 29, 2022, 6:46pm
37
The extra 0 I inserted to ask you.
The solution by andrew jones is the only one which works.
I tried your solution - By removing 0 and let jason attributes path work (and append 0 while making the call). But it doesnot fill any of my hvac_x sensors.
Solution by Andrew works (ie, each resource is expicitly made - including 0, 1 etc in the end). Hvac_x is filled and data comes in.
This is working
resource: http://192.168.39.14/app/config/0/0
sensor:
- name: "hvac_0"
value_template: "OK"
json_attributes:
- "Result"
There is only one call for one resource (even when using andres solution)- So that problem is solved.
My new problem(or maybe connected to this problem) is some kind of rate limiting by HA. Every few seconds my sensors go unavailable.
petro
(Petro)
August 29, 2022, 6:49pm
38
does your device return a response without the trailing zero? If thatâs the case, thatâs a limitation of your device, not a limitation of the rest integration.
that means your device isnât returning a response. Check your logs for errors. It will only go unavailable if it doesnât get a response when it requests information.
nitinuae
(Nitinuae)
August 29, 2022, 6:55pm
39
Ah - got the problem here.
The device does respond to
http://192.168.39.14/app/config/ <â This is root giving me device hw etc
http://192.168.39.14/app/config/0 <â This is config of device(how its configured)
http://192.168.39.14/app/config/0/x â This is the data I am interested.
The rate limitation is this -
2022-08-29 20:15:19.048 DEBUG (MainThread) [homeassistant.helpers.ratelimit] Reached rate limit of 0:01:00 for Template("{{ state_attr(âsensor.hvac_1â,âResultâ)[âPointâ][2][âValueâ] }}") and deferred action until 2022-08-29 16:16:19.011208+00:00
I posted thread here
https://community.home-assistant.io/t/rate-limit-rest-api-undocumented/455244
petro
(Petro)
August 29, 2022, 7:07pm
40
Thatâs a template rate limit, something is seriously wrong if your single sensor is causing it to go into a rate limit. You wonât have that rate limit if you just use a single rest setup.
Assuming you canât call them separately, this is the smallest and most concise configuration for it.
rest:
- resource: http://192.168.39.14/app/config/0/0
<<: &hvac_auth
authentication: basic
username: "xx"
password: "xx"
scan_interval: 7
sensor: &hvac_sensors
- name: "ctr_type"
state: "{{ value_json.Result.Point[0].Value }}"
- name: "runstate"
state: "{{ value_json.Result.Point[1].Value }}"
- name: "CHIL_S_S"
state: "{{ value_json.Result.Point[2].Value }}"
- name: "CHIL_OCC"
state: "{{ value_json.Result.Point[3].Value }}"
- name: "min_left"
state: "{{ value_json.Result.Point[4].Value }}"
- name: "ALM"
state: "{{ value_json.Result.Point[7].Value }}"
- name: "CAP_T"
unit_of_measurement: "%"
state: "{{ value_json.Result.Point[13].Value }}"
- name: "SP"
unit_of_measurement: "°C"
state: "{{ value_json.Result.Point[17].Value }}"
- name: "CTRL_PNT"
unit_of_measurement: "°C"
state: "{{ value_json.Result.Point[18].Value }}"
- name: "CTRL_WT"
unit_of_measurement: "°C"
state: "{{ value_json.Result.Point[19].Value }}"
- name: "OAT"
unit_of_measurement: "°C"
state: "{{ value_json.Result.Point[20].Value }}"
- resource: http://192.168.39.14/app/config/0/1
<<: *hvac_auth
sensors: *hvac_sensors
- resource: http://192.168.39.14/app/config/0/2
<<: *hvac_auth
sensors: *hvac_sensors
- resource: http://192.168.39.14/app/config/0/3
<<: *hvac_auth
sensors: *hvac_sensors
- resource: http://192.168.39.14/app/config/0/4
<<: *hvac_auth
sensors: *hvac_sensors
- resource: http://192.168.39.14/app/config/0/5
<<: *hvac_auth
sensors: *hvac_sensors