Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 102800

Help with dynamic json sensors

$
0
0

Hello,
What I want to achieve is populate dynamic sesnors from xml file attached bellow. Now what I can achieve is to using this config and populatin each manually. The issue is that listeners are various amount. How to mane it dynamic?

rest: 
  resource: https://redacted
  method: GET
  scan_interval: 120 
  sensor:
    - name: "Radio 1"
      json_attributes_path: "$.LISTENERS.Listener[0]"
      value_template: "OK"
      json_attributes:
        - IP
        - Status
        - Pts
    - name: "Radio 2"
      json_attributes_path: "$.LISTENERS.Listener[1]"
      value_template: "OK"
      json_attributes:
        - IP
        - Status
        - Pts
    - name: "Radio 3"
      json_attributes_path: "$.LISTENERS.Listener[2]"
      value_template: "OK"
      json_attributes:
        - IP
        - Status
        - Pts
    - name: "Radio 4"
      json_attributes_path: "$.LISTENERS.Listener[3]"
      value_template: "OK"
      json_attributes:
        - IP
        - Status
        - Pts
    - name: "Radio 5"
      json_attributes_path: "$.LISTENERS.Listener[4]"
      value_template: "OK"
      json_attributes:
        - IP
        - Status
        - Pts
    - name: "Radio 6"
      json_attributes_path: "$.LISTENERS.Listener[5]"
      value_template: "OK"
      json_attributes:
        - IP
        - Status
        - Pts
    - name: "Radio 7"
      json_attributes_path: "$.LISTENERS.Listener[6]"
      value_template: "OK"
      json_attributes:
        - IP
        - Status
        - Pts
<LISTENERS>
<Listener>
<Status>1</Status>
<Station>Radio 2</Station>
<IP>127.0.0.1</IP>
<SubID>0</SubID>
<NextPayment>1651142286</NextPayment>
<Feedback>1651141566</Feedback>
<Pts>3.75</Pts>
</Listener>
<Listener>
<Status>1</Status>
<Station>Radio 2</Station>
<IP>127.0.0.1</IP>
<SubID>0</SubID>
<NextPayment>1651141682</NextPayment>
<Feedback>1651141562</Feedback>
<Pts>1.50</Pts>
</Listener>
<Listener>
<Status>1</Status>
<Station>Radio 2</Station>
<IP>127.0.0.1</IP>
<SubID>0</SubID>
<NextPayment>1651142227</NextPayment>
<Feedback>1651141567</Feedback>
<Pts>12.00</Pts>
</Listener>
<Listener>
<Status>1</Status>
<Station>Radio 3</Station>
<IP>127.0.0.1</IP>
<SubID>0</SubID>
<NextPayment>1651141722</NextPayment>
<Feedback>1651141542</Feedback>
<Pts>12.00</Pts>
</Listener>
<Listener>
<Status>1</Status>
<Station>Radio 2</Station>
<IP>127.0.0.1</IP>
<SubID>0</SubID>
<NextPayment>1651141995</NextPayment>
<Feedback>1651141575</Feedback>
<Pts>0.50</Pts>
</Listener>
<Listener>
<Status>1</Status>
<Station>Radio 2</Station>
<IP>127.0.0.1</IP>
<SubID>0</SubID>
<NextPayment>1651141813</NextPayment>
<Feedback>1651141573</Feedback>
<Pts>9.00</Pts>
</Listener>
<Listener>
<Status>1</Status>
<Station>Radio 3</Station>
<IP>127.0.0.1</IP>
<SubID>0</SubID>
<NextPayment>1651141933</NextPayment>
<Feedback>1651141573</Feedback>
<Pts>3.00</Pts>
</Listener>
</LISTENERS>

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 102800

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>