Entity with variable number of attributes

I’m just starting my adventure with HA and just learning the basic stuff.
Here’s the problem I need help with. I have a device that exposes REST API. I can get certain values with RESTful sensor and also change the device’s state with RESTful command. However, this is the thing.
The device has configurable profiles, each profile sets the certain number of parameters. A user can create as many profiles as they want. I can get the list of existing profiles with the REST, here’s the response.


And it also has a parameter which indicates the ID of the current active profile:


I actually can activate the desired profile with REST command, but it’s static. Meaning I should already know the list of profiles and which ID is assigned to each profile.

What I’d like:

  • have some card which lists all the available profiles
  • switch between them clicking a button of a desired profile

Any idea how this could be implemented?

Here’s my current configuration:

  - platform: rest
    resource: https://zont-online.ru/api/devices
    name: zont
    method: POST
    timeout: 50
    scan_interval: 60
    force_update: true
      X-ZONT-Client: !secret x_zont_client
      X-ZONT-Token: !secret x_zont_token
      Content-Type: application/json
    payload: '{"load_io": true}'
    picture: https://zont-online.ru/wp-content/themes/zont/images/logo-footer.svg
    icon: https://zont-online.ru/wp-content/themes/zont/images/thumb_icon/gsm.svg
    value_template: '{{ value_json.ok }}'
    json_attributes_path: "$.[0]"
      - thermometers
      - io
      - thermostat_ext_mode
      - thermostat_ext_modes_config
      - id

    url: https://zont-online.ru/api/update_device
    method: POST
      X-ZONT-Client: !secret x_zont_client
      X-ZONT-Token: !secret x_zont_token
      Content-Type: application/json
    payload: '{"device_id": xxxxx,"thermostat_ext_mode": 1 }'

  - sensor:
    # Thermostat mode
    - name: "Curent mode"
      state: > 
        {% if state_attr('sensor.zont', 'thermostat_ext_mode') is not none %}
            {% set mode = '' ~ state_attr('sensor.zont', 'thermostat_ext_mode') ~ '' %}
            {{ state_attr('sensor.zont', 'thermostat_ext_modes_config')[mode].name }}
        {% endif %}

OK, I managed to complete almost evetything. I took input_select as a solution. The only thing remaining is how to set the varailbe options for the input_select? I see there is set_options service, however I didn’t find a way to set dynamic options for it. Does anyone have any recommendation?

Make a template select instead of using an input_select. It’s designed to handle this. If you need help with that, post the entity_id and it’s attributes here and I’ll help.

Hi Petro!
Thanks for offering help, I definitely need it. However, I don’t really understand which entity_id and attributes are required… Can you please clarify?

Hi again
Thanks a lot for the hint! Though the template select documentation is very poor, I managed to find an example and achieved my goal. Thanks!