LVGL - keyboard/textarea causes reboots

I would love anyones help - been going back and forth on this one for forever and there is no real world examples in the forums for either the keyboard or textarea yet.

I have existing code, but at the moment I’m on my phone so can’t post that bit yet.

I have a dropdown list that shows a number of input_text entities in HA.

I have a keyboard and textarea set up.

How do I get the value of the textarea to populate the value of the selected dropdown item (which points to a HA input_text) with the value of the textarea?

Surprisingly the action, on_ready: works with both keyboard and textarea despite it not being documented in textarea.

TBH: I can actually get it to work on the first value of the dropdown (0). But if I move to the second value, the esp32 reboots.

Logs don’t say anything (cos it reboots before it sends the log)

As I said - am on my phone (on the train) and would really love to see how someone else would achieve this.

Thanks.

  1. Really, there’s not much point in even asking without sample code.
  2. Serial logs will show information about exceptions causing reboots.
  3. I assume you’re using a lambda to get the dropdown text - this is most likely what is causing the exception.

Just dont know if im going about this the right way and Im not the best at lambdas.

Whenever I touch the mainpage button, it reboots the screen
Pls not I have redacted most of the code because it has GROWN (about 3.5k lines)

    globals:
      - id: selected_option
        type: int
        initial_value: '0'


#######################
# On the settings page
#######################

    - dropdown:
        id: assign_dropdown
        width: 100
        x: 200
        y: 50
        options:
          - OPTION1
          - OPTION2
        on_value:
          then:
          # Save the selected option in the global variable
            - lambda: |-
                id(selected_option) = x;  


######################
# On the title_entry_page
######################
    - textarea:
        id: textarea_1
        text: "blanktext"
        text_font: barlow60
        align: top_mid 
        one_line: true           
        bg_color: 0x000000
        bg_opa: 0%
        border_color: 0x000000
        border_opa: 0%
        y: -10
        text_color: 0xFFFFFF
        on_ready:
          then:
            - if:
                condition:
                  lambda: 'return id(selected_option) == 0;'  # For dropdown1
                then:
                  - lvgl.label.update:
                      id: [ mainpage, sspage, settingspage ]
                      text:
                        format: "%s"
                        args: [ 'text.c_str()' ]
                  - homeassistant.service:
                      service: input_text.set_value
                      data:
                        entity_id: input_text.entity1
                        value: !lambda 'return text.c_str();'

            - if:
                condition:
                  lambda: 'return id(selected_option) == 1;'  # For dropdown2
                then:
                  - lvgl.label.update:
                      id: [ mainpage, sspage, settingspage ]
                      text:
                        format: "%s"
                        args: [ 'text.c_str()' ]
                  - homeassistant.service:
                      service: input_text.set_value
                      data:
                        entity_id: input_text.entity2
                        value: !lambda 'return text.c_str();'


        - keyboard:
            id: keyboard_id
            textarea: textarea_1
            mode: TEXT_UPPER
            bg_color: 0x000000
            bg_opa: 0%
            items: 
              bg_color: 0x2F8CD8
              bg_grad_color: 0x005782
              bg_grad_dir: VER
              bg_opa: COVER
              border_color: 0x0077b3
              border_width: 1
              text_color: 0xFFFFFF                 

##################
# on the main/first page
##################

        - button:
            id: mainpage_title_button
            align: top_mid
            width: 350
            height: 60
            bg_color: 0x000000
            bg_opa: 0%    
            border_width: 0
            border_color: 0xff0000
            border_opa: 0%        
            shadow_color: 0x000000
            shadow_opa: 0x000000  
            widgets:
              - label:
                  id: mainpage
                  text_font: barlow60
                  text: "title goes here"
                  align: center
                  bg_color: 0x000000
                  bg_opa: 0%
                  border_color: 0xff77aa
                  border_opa: 0%
                  border_width: 0
            on_press:
              then:
                - lvgl.page.show: title_entry_page      

You can’t return the value of c_str() - it ceases to exist when the lambda returns. Just return text.

Thanks clyde.
I had to re-assess the way I was doing the code, but I implemented your solution and now no crashes.
Tq

1 Like