Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Populating/Updating dropdown roller btnmatrix items at runtime (after HA connected) #46

Open
nagyrobi opened this issue Jan 22, 2024 · 0 comments

Comments

@nagyrobi
Copy link

nagyrobi commented Jan 22, 2024

Use cases:

  • display light's effect_list attribute
  • media player's source_list and sound_mode_list
  • any select options import from HA

Items for dropdown roller and btnmatrix are natively added to the widgets with a string where \n is the delimiter.

For example importing the sound_mode_list attribute of media_player.my_room into an ESPHome text sensor with filters:

text_sensor:
  - platform: homeassistant
    name: "Media Player sound modes"
    id: mplaymodes
    entity_id: media_player.my_room
    attribute: sound_mode_list
    filters:
      - substitute:
        - "', '-> \\n"
        - "[ -> "
        - "] -> "
        - "' -> "

results in:
Classic\nJazz\nNormal\nPop\nVocal
which can be used to directly populate a dropdown roller or a btnmatrix with these items.

Suggestion for dropdown roller and btnmatrix would be to have a config option like text_items which could accept strings like above mutually exclusive with buttons >text or symbol sub-options. The other styling options could still be possible per item.

With lvgl.widget.update this could be updated at runtime.

Also in pair with #40

Use case for the example above is with on_value the user could call a HA service to choose the desired sound mode (we need the selected item name in a variable, see #49 (comment))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant