@riaandeyzel wrote:
How do I get the status (name, enabled, pump & state) of the following JSON endpoint:
This is what I currently have in my sensor.yaml:
- platform: rest scan_interval: 10 #7200 Seconds = 2 Hours resource: http://10.0.0.50:8080/json/zones name: Zones value_template: >- {% for zones in value_json.zones if zone.location == 'zones' and name.Title == 'Zone 1' %} {{ zone.value | float / 100 }} {% endfor %} json_attributes: - name - enabled - pump - state headers: Referer: http://10.0.0.50:8080/json/zones # unit_of_measurement: '%' - platform: template sensors: zone_1_name: friendly_name: "Zone 1 Name" value_template: '{{ states.sensor.zones.attributes["name"] }}' zone_1_enabled: friendly_name: "Zone 1 Enabled" value_template: '{{ states.sensor.zones.attributes["enabled"] }}' zone_1_pump: friendly_name: "Zone 1 Pump" value_template: '{{ states.sensor.zones.attributes["pump"] }}' zone_1_state: friendly_name: "Zone 1 State" value_template: '{{ states.sensor.zones.attributes["state"] }}'
Here is the endpoint info at http://10.0.0.50:8080/json/zones:
{ "zones" : [ {"name" : "Zone 1", "enabled" : "on", "pump" : "on", "state" : "off" }, {"name" : "Zone 2", "enabled" : "on", "pump" : "on", "state" : "off" }, {"name" : "Zone 3", "enabled" : "on", "pump" : "on", "state" : "off" }, {"name" : "Zone 4", "enabled" : "on", "pump" : "on", "state" : "off" }, {"name" : "Zone 5", "enabled" : "on", "pump" : "on", "state" : "off" }, {"name" : "Zone 6", "enabled" : "on", "pump" : "on", "state" : "off" }, {"name" : "Zone 7", "enabled" : "on", "pump" : "on", "state" : "off" }, {"name" : "Zone 8", "enabled" : "off", "pump" : "off", "state" : "off" }, {"name" : "Zone 9", "enabled" : "off", "pump" : "on", "state" : "off" }, {"name" : "Zone 10", "enabled" : "off", "pump" : "on", "state" : "off" }, {"name" : "Zone 11", "enabled" : "off", "pump" : "on", "state" : "off" }, {"name" : "Zone 12", "enabled" : "off", "pump" : "on", "state" : "off" }, {"name" : "Zone 13", "enabled" : "off", "pump" : "on", "state" : "off" }, {"name" : "Zone 14", "enabled" : "off", "pump" : "on", "state" : "off" }, {"name" : "Zone 15", "enabled" : "off", "pump" : "on", "state" : "off" } ]}
I just get a blank reply.
I also think that there should be a simpler way to get the values for name, enabled, pump & state.
Posts: 1
Participants: 1