#REST Calling JSON File => Multiple Sensor entities
1 messages · Page 1 of 1 (latest)
I´m loading a rather big JSON file and wante to create multiple sensor values from it, using different json paths... but it's not really working...
here is what i have rightnow:
https://dpaste.org/j1YUu
post what the data looks like
i tried to use the json-paths within the value_templates but that didn't work
cant paste the data - it's confidential - but i have validated that the json_paths are correct and working
is it xml or json?
use
"{{ value_json.clients | selectattr('name','eq','Client Name') | map(attribute='cost.formatted') | first }}"
without the path
as the value template?
yes
interesting! give me a sec..
there we go! works like a charm!
thanks man!
enjoy a ☕️ on me! 🙂
Thanks 🙂
make sure it works during restarts
I suspect you'll need a |default in case the map doesn't work
after the | first
the only way it wouldn't work is if you got an empty response from your endpoint
just like "{{ value_json.clients |default selectattr('name','eq','Client Name') | map(attribute='cost.formatted') | first }}" ?
sorry - not familiar with this kind of mapping
no, after | first
they are filters
you start with value_json.clients
it then widdles the list down with | selectattr('name','eq','Client Name')
oh, i understand now...