-
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
on_value
for more widgets
#49
Comments
I was just thinking when i was playing with the button on_click event. - 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; |
|
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; |
But that's exclusive to |
true. for other sensors atc the |
Was thinking about this |
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 Not sure if things like |
Works with all event triggers now. |
We need
on_value
for widgets supportingcheckable: true
, (btn
,checkbox
,switch
etc) to make automations easier when theLV_EVENT_VALUE_CHANGED
happens.For examle here we have a checkable button with a label on it, and we want to show a differently coloured symbol based on the button's checked state.
If
on_value
could return a binary valuex
inchecked
state, this would be easy to accomplish in the same yaml section, without having to rely on binary sensors etc.dropdown
roller
andbtnmatrix
could benefit fromon_value
if it would return the indexx
and the namen
of the selected option after theLV_EVENT_VALUE_CHANGED
occured.We also need the name in a variable
n
as string because HA'sselect.select_option
only offers selecting options by name, not index. ESPHome's select locally supports index too, LVGL supports only index when updating the widget so it would be nice to have both in the trigger.The text was updated successfully, but these errors were encountered: