HA structure to save dictionaries


I have an IP camera. I want to position it to PTZ presets received from the camera.
Using REST I can get a JSON structure with presets. Now I wat to create something like python dictionary in Home Assistant. For example

{"ptzname": 1,"ptzname2": 2,"ptzname3": 3}

After that I want to call service some service with camera name and “ptzname1” parameter and it will send a REST with a digit “1”.

I can do that creating input_number named “imput_number.ptzname1”, “imput_number.ptzname1”, “imput_number.ptzname1” and so on. But that is not a dynamic configuration. Each time I will create or change PTZpreset in the camera I must modify configuration and make a HA restart.

Is there any option to do so?



Take a look at this integration, it might suit your need. It’s available in HACS:

Interestind, thanks.

Looks like cause of creating this addon are similar to I haved when was trying to setup dynamic emojis for a bunch of my temperature sensors. Will check and maybe migrate this automation for that task.

But I don’t see a dictrionary type. And I don’t see how I can create a new variable when I receive a new PTZ from camera.

Ok then, what you could do is to create a dummy input_boolean sensor for which you will just ignore its state but using it just for storing data by setting custom attributes on it.
See attachements below

friendly_name: Test Condition is just one of my testing entities, just ignore that line.
This can be done dynamically and will persist over HA restart.
You will need to load saved_ptz root dictionnary, update the entry you need in it and finally save back the whole dictionnary to your entity attributes.

You can do all of this by playing within the developper Template page.
Few google/topic search will help you to find how to set attributes on entities.

1 Like