How to create sensor containing JSON items of only internal origin?

The general principle is demonstrated by the following example:

It’s a Trigger-based Template Sensor that employ custom events to add/delete items from a dictionary stored in one of its attributes. If you don’t want a dictionary, you can change it to a list. Either way, the data can be retrieved, using the state_attr() function, for use or display elsewhere.