Hi !
I’m using Opensprinkler as water system and I use its HA Integration to manage start, stop and program of my sprinkler stations.
The HA Opensprinkler integration doesn’t provide history log entity, I have to go on Opensprinkler local website to get it.
But Opensprinkler provide an API to get that info.
Here is what kind of data I can get from the log endpoint :
[
[99, 2, 6, 1720344992],
[99, 3, 600, 1720345809],
[99, 3, 600, 1720347955],
[99, 0, 16, 1720352180],
[99, 0, 12, 1720352232],
[99, 0, 32, 1720352670],
[99, 0, 7, 1720352772],
[2, 1, 300, 1720355401],
[2, 2, 300, 1720355701]
]
My goal is to get every row of this data (wich is not a known number beacause it depends of the number of entry in the log), and for each row, I have to map each number with a reference array to get text data and finally display it in lovelace.
But I meet some issue at the beginning of this project
Here is a first try, just to get the first row and each number of this first row :
sensor:
- platform: rest
name: My API Sensor
resource: "http://192.168.1.174/jl?pw=368b2efc3406b3e44f41e2f5e2be323b&hist=0"
method: GET
headers:
Content-Type: application/json
value_template: "{{ value_json[0] }}"
json_attributes:
- data
scan_interval: 20
- platform: template
sensors:
first_element_first_list:
value_template: "{{ state_attr('sensor.my_api_sensor', 'data')[0} }}"
second_element_first_list:
value_template: "{{ state_attr('sensor.my_api_sensor', 'data')[1] }}"
third_element_first_list:
value_template: "{{ state_attr('sensor.my_api_sensor', 'data')[2] }}"
fourth_element_first_list:
value_template: "{{ state_attr('sensor.my_api_sensor', 'data')[3] }}"
With that, sensor.my_api_sensor state is [99, 2, 6, 1720344992]
But sensor.first_element_first_list state is unknown whereas I’m expecting “99”
Could somebody help me with that please