Hi,
trying to create a sensor for my Hue hub’s capabilities, I am unsure how to proceed. I think know how to set the json_attributes, but the value_template is the issue, since that can only hold the full string of the resource, which is way to long…
the resource would be in this form:
http://192.168.1.212/api/resource_id/capabilities
and then the sensor config could be:
- platform: rest
name: Hue capabilities
resource: !secret hue_capablities_resource
# authentication: basic
value_template: >
{{ value_json }}
json_attributes:
- lights
- sensors
- clip
- zll
- zgp
- groups
- scenes
- lightstates
- schedules
- rules
- conditions
- actions
- resourcelinks
- streaming
headers:
Content-Type: application/json
Authorization: !secret api_bearer_token
User-Agent: Home Assistant REST sensor
Not sure about the bottom part, since I don’t need to access the HA instance, but this is a copy of another rest sensor in my system for now.
The output of the resource is:
{"lights":{"available":18,"total":63},
"sensors":{"available":174,"total":250,
"clip":{"available":174,"total":250},
"zll":{"available":45,"total":64},
"zgp":{"available":45,"total":64}},
"groups":{"available":35,"total":64},
"scenes":{"available":0,"total":200,
"lightstates":{"available":0,"total":12600}},
"schedules":{"available":92,"total":100},
"rules":{"available":53,"total":250,
"conditions":{"available":848,"total":1500},
"actions":{"available":590,"total":1000}},
"resourcelinks":{"available":44,"total":64},
"streaming":{"available":1,"total":1,"channels":10},
"timezones":{"values":["CET","CST6CDT","EET","EST","etcetcetcetc"]}}
the “timezones” part of the output makes me need to exclude that (or as in the above effort, list all included attributes), because it is a full list of all available timezones, which is way to long for the sensor, and not necessary at that.
Or, should I maybe create a template sensor using attribute_templates
? In which case the question would remain: how to set the main template, on which to base the attributes belonging to it?
please have a look with me, thanks!