-
Notifications
You must be signed in to change notification settings - Fork 11
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
Selecting dropdown
roller
btnmatrix
items by item name
#52
Comments
Can you provide an example for this? The select entity exposed to HA uses an index, not a string. Setting the value via an arbitrary text value might not work, as it would have to match exactly, so what should happen if it matches none of the options? |
I may have ran a bit fast... :) End goal is to present in LVGL a dropdown, roller or btnmatrix mirroring a select from HA corresponding to some other integration. Like in the examples from the cookbook, you use a switch widget in LVGL to toggle an arbitrary light switch in HA, or adjust various other entities, you need to retrieve their state first from HA with For example you have in HA a options:
- Base
- Mid
- High
- Turbo
- Off
icon: mdi:fan
friendly_name: Ventilation presets This select's state can only be a textual value, one of the options listed eg. state: We could create a dropdown, roller or btnmatrix in LVGL with exactly these options (also see #46): lvgl:
...
- dropdown:
id: vent_dropdown
options:
- Base
- Mid
- High
- Turbo
- Off and a text sensor to retrieve the state, which would have to use a resolution function to update the dropdown't selected value by the name, since there's no index available: text_sensor:
- platform: homeassistant
id: ventilation_system_select_state
entity_id: select.ventilation_system
on_value:
- lvgl.dropdown.select:
id: vent_dropdown
item_name: !lambda return x.c_str(); #or similar
Nothing, just a warning in ESPHome log (the chances to occur would be minimized if #46 would be possible). Moreover, if we would have |
Just use a select linked to the roller/dropdown, and use automations in HA to sync with something else.
|
The above described approach would be better in the sense that the whole procedure would be done in a single place, the ESPHome node. Wouldn't require additional configs to maintain in the middleware (HA). Pretty much the same reason as why avoiding MQTT in general. Plus afaik there's no easy way to sync entities to each other in HA (say, two |
At least if we could have lambda equivalents for this. Say, consider this an advanced use case, which typically lambdas are apropriate for. |
There is:
which is good if we know the index number.
The corresponding HA integrations which could be used with these widgets use states which show not the index, but the name of the currently selected option.
We need a shortcut/wrapper for the action above which could be able to resolve the index from the name, something like:
Use case: with a text sensor we can retrieve the current state name from HA, and with the just call
lvgl.**.select
withitem_name
parameter to select the item with the same name.The text was updated successfully, but these errors were encountered: