Giter Site home page Giter Site logo

`on_value` for more widgets about esphome HOT 8 CLOSED

nagyrobi avatar nagyrobi commented on June 20, 2024 1
`on_value` for more widgets

from esphome.

Comments (8)

nielsnl68 avatar nielsnl68 commented on June 20, 2024 1

true. for other sensors atc the on_value can be useful indeed.

from esphome.

nielsnl68 avatar nielsnl68 commented on June 20, 2024

I was just thinking when i was playing with the button on_click event.
Would it be nice to have the "homeassistant.service" build into the widgets directly.
so you have for example:

     - btn:
            checkable: true
            id: btn_toggle_swicth
            widgets:
              - label:
                  id: lbl_btn_apa_lampa
                  align: center
                  text_color: 0xFFFFFF
                  symbol: CLOSE
            homeassistant.service:
               entity_id: light.to_be_toggled
               send: light.turn_off
               receive:
                  state:
                      checked: !lambda return x;

        - dropdown:
            x: 80
            y: 180
            width: 105
            id: dropdown_id
            options:
              - Dry food
              - Wet food
              - Semi-moist
            homeassistant.service:
               entity_id: light.to_be_toggled
               send: 
                  action: light.turn_off
                  option: !lambda return (n.c_str());
               receive:
                  value: !lambda return x;

from esphome.

nagyrobi avatar nagyrobi commented on June 20, 2024

receive?

from esphome.

nielsnl68 avatar nielsnl68 commented on June 20, 2024

Yes, that would be like a short way of:

binary_sensor:
- platform: homeassistant
  publish_initial_state: true
  id: "light_totom"
  entity_id: light.woonkamer_kleuren_totom_light_1
  on_state:
    - lvgl.widget.update:
        id: lv_button0
        state:
          checked: !lambda return x;

from esphome.

nagyrobi avatar nagyrobi commented on June 20, 2024

But that's exclusive to homeassistant.service, right? Still need on_value for regular esphome automations...

from esphome.

nagyrobi avatar nagyrobi commented on June 20, 2024

Was thinking about this homeassistant.service and I think we still need the binary sensor though, to get the initial state of the entity from HA, to display it before calling the service.

from esphome.

nagyrobi avatar nagyrobi commented on June 20, 2024

Ran into a use case with a switch:

              - switch:
                  id: swi_klima
                  x: 45
                  y: 68
                  align: TOP_MID
                  width: 70 #75
                  height: 40
                  on_release:
                    - if:
                        condition:
                          lambda: return lv_obj_get_state(id(swi_klima)) & LV_STATE_CHECKED;
                        then:
                          - homeassistant.service:
                              service: climate.set_hvac_mode
                              data:
                                hvac_mode: !lambda |-
                                  if (id(bs_climate_heat_mode).state == true) {
                                      return "heat";
                                  } else {
                                      return "cool";
                                  }
                                entity_id: climate.haloszoba_klima
                        else:
                          - homeassistant.service:
                              service: climate.turn_off
                              data:
                                entity_id: climate.haloszoba_klima

We could just use x here instead of lv_obj_get_state(id(swi_klima)) & LV_STATE_CHECKED in an on_value trigger.

Not sure if things like on_turn_on and on_turn_off or more LVGL-specialised on_check and on_uncheck would be worth it.

from esphome.

nagyrobi avatar nagyrobi commented on June 20, 2024

Works with all event triggers now.

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.