How to parse rolling JSON with rest

Hi Guys
Looking for idea how to parse rolling json file, the json file look like this:

<response><b0>     Salt Level </b0><b1>          3.4 g/</b1></response>
then 5 second later
<response><b0>      Saturday  </b0><b1>           08 49</b1></response>
then 5 second later
<response><b0>  Pool Chlorinat</b0><b1>or          20% </b1></response>
then 5 second later
<response><b0>      Heater1   </b0><b1>        Auto Con</b1></response>
then 5 second later
<response><b0>  Pool Temp  27Ɵ</b0><b1>C               </b1></response>
and so on
<response><b0>  Air Temp   16Ɵ</b0><b1>C               </b1></response>

I just need to catch salt level value, I successfully get data like this:

sensor:
    - name: "JSON Pool Keypad Status"
      json_attributes:
      - b0
      - b1
      value_template: "OK"
      json_attributes_path: "$.response"
      force_update: true
    - name: Title
    
      value_template: "{{ value_json.response.b0 }}"
    - name: Value
      value_template: "{{ value_json.response.b1 }}"

but Iā€™m unable to isolate my salt level value, any clue?

Any clue ?

Template sensor (UI, Helpers), state template:

{% set a = states['sensor']['json_pool_keypad_status']['attributes'] %}
{% if 'Salt Level' in a['b0'] %}
  {{ a['b1']|select('in','0123456789.')|join() }}
{% else %}
  {{ this.state }}
{% endif %}

Many tks, he works as expected :+1:

1 Like