I’m using a REST Sensor with the json_attributes attribute to retrieve a high level JSON field devices which in itself is another JSON object. This object is then stored in the sensor state attributes. How do I parse this JSON object to retrieve a particular field from it?
What I want to retrieve is the gateway status plus the taplinker status.
Thanks for the reply. I knew how to drill down to the element I wanted but not how to extract it from within the sensor state attributes. I figured it out… a lot simpler than I thought:
It took me a long time to find this thread for a similar issue! However I’m wondering if there’s a way to put more of this within the state_attr function, since that won’t error out if the attribute doesn’t exist.
My use case is with the SureHA (SurePet flap/feeders) integration, for an attribute “feeding” which might not exist for every pet, e.g. the below causes an error because pet_bella has no feeding data:
Actually I can work around this in my case as I know pet_Bella won’t have feeidng data, and I’m sure there’s something I could wrap around this to make it error-resistant, but was hopign to do something graceful like have state_attr handle that for me.