what i’ve done in the meantime is edit my python code thats extracting the json and removing the first port reference and attributes. So port 2 is always at the top.
But I like your version more because I can see all the ports regardless. I’ll give it go now.
You could, assuming the ports are always in the correct order in the JSON.
My json_attributes_path and value_template (optional, but puts the port state in the sensor state rather than a blanket 'ok') actually look up the correct port, so if the device decides to mix up the order it’ll still work.
@dharvey24: Unique IDs are a good idea: I would use them in production and only omitted them here for brevity. I use this site to generate them: https://www.uuidgenerator.net/
They allow for customisation in the UI and assigning to an area.
yes but according to his json output it does not put all the states in value_template.
so normally it stores the data in the sensor itself where i can use that sensor to create template sensors with my data.
that’s why i copied my code in the beginning to use template sensors instead when the data has been retrieved, but had no knowledge of how his json would look like.
But u right yours does have a sort of fail safe if the data decides to mix up, so if i was @dharvey24 in this case i would use your code as shown in post #22
in my instance it doesn’t mix up the results, it would be the same each and every time. However its useful to understand how this works for other applications. @Troon and @malosaa thank you for taking the time to assist. I’m now just sorting out the notifications which I can do. For those following to install the requests and bs4 modules for python I used an automation and shell_command line to install them on startup.