JSON Array into Sensor With Attributes

I have a budget setup on a separate site and I have an API that I built to pull data out of it. Below is an example of the response where it gives me the category, amount spent, and amount remaining as an array. What I’d like to do is turn each element of the larger array into a sensor that then has attributes I can reference and display on my HA dashboard. So this would be the response:

[["Category","Amount Spent","Amount Remaining"],["Eating Out","-$17.27","$382.73"],["Groceries","-$146.69","$353.31"],["Gas","$0.00","$250.00"],["Entertainment","-$29.83","$259.28"]]

And then this element of that array:

["Eating Out","-$17.27","$382.73"]

Would get turned into a sensor called like: sensor.budget_eating_out and have two attributes “amount_remaining” and “amount_spent” and the values from the above array would assigned appropriately.

I’ve never dealt with a JSON array as a response from an API in the context of HA sensors so I was hoping someone may have done something similar and could point me in a direction to tackle this?

1 Like