Giter Site home page Giter Site logo

Comments (5)

clydebarrow avatar clydebarrow commented on September 22, 2024

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?

from esphome.

nagyrobi avatar nagyrobi commented on September 22, 2024

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 platform: homeassistant kind of sensor first.

For example you have in HA a select.ventilation_system (provided by some other integration) with some presets:

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: Base

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

what should happen if it matches none of the options

Nothing, just a warning in ESPHome log (the chances to occur would be minimized if #46 would be possible).

Moreover, if we would have on_value for dropdown/roller/btnmatrix, we could do the reverse, update the select in HA based on the choice made here as described in #49.

from esphome.

clydebarrow avatar clydebarrow commented on September 22, 2024

Just use a select linked to the roller/dropdown, and use automations in HA to sync with something else.

select:
  - platform: lvgl
    dropdown: lv_dropdown
    name: LVGL Dropdown

from esphome.

nagyrobi avatar nagyrobi commented on September 22, 2024

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 selects), there's always the possibility to enter in a sync loop etc. Harder for users...

from esphome.

nagyrobi avatar nagyrobi commented on September 22, 2024

At least if we could have lambda equivalents for this. Say, consider this an advanced use case, which typically lambdas are apropriate for.

from esphome.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.