Earlier I had suggested the same so it puzzles me why so much time and effort is being expended to cram many URLs into something that can only hold 255 characters. Plus it would appear that the source feeding this template sensor may already be a restful sensor:
Thanks @tboyce1 and @123 , yes indeed, my source is a restful sensor and I get the attributes as json form the openSprinklerBee:
- platform: rest
method: GET
name: programas_osbee
resource: !secret opensprinklerbee_devip_getPrograms
json_attributes:
- progs
I tried to explain above what I was trying to do but here I go again:
The state obtained from this restful sensor is something like:
{“tmz”:56,“progs”:[{“config”:65539,“sts”:[1260,-1,-1,-1,-1],“nt”:3,“pt”:[153601,153602,153604],“name”:“Atardecer”},{“config”:32513,“sts”:[660,-1,-1,-1,-1],“nt”:2,“pt”:[76802,76804],“name”:“Mediodia”}]}
But what I get from it is an attribute called ‘progs’ that is a list of irrigation programs, without knowing the exact number of programs in the device(in the above example, there are 2 only).
Then, I want to take them and convert one of its parameters to disable the programs: the config parameter, by setting it to config-1 if it was an even number.
Once I have the whole list of progs modified stored somewhere, I have to send it one by one to the device in order to change the programs within the device. I was thinking of doing that with cURL using the rest api syntax of the device and shell command.
I was trying to do it with templates in order to be able to iterate between progs as I was supposing not knowing the number of programs to be modified.
Maybe there is a much easier way of doing that but I don’t have a clue. Again, sorry for being a noob, any idea is appreciated.