[lvgl] Fix set state on updates (#7227)

This commit is contained in:
Clyde Stubbs 2024-08-08 18:24:10 +10:00 committed by GitHub
parent b71c03424e
commit a47a17d7e7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 3 deletions

View File

@ -1,9 +1,9 @@
#pragma once #pragma once
#include "esphome/core/defines.h" #include "esphome/core/defines.h"
#ifdef USE_LVGL_BINARY_SENSOR #ifdef USE_BINARY_SENSOR
#include "esphome/components/binary_sensor/binary_sensor.h" #include "esphome/components/binary_sensor/binary_sensor.h"
#endif // USE_LVGL_BINARY_SENSOR #endif // USE_BINARY_SENSOR
#ifdef USE_LVGL_ROTARY_ENCODER #ifdef USE_LVGL_ROTARY_ENCODER
#include "esphome/components/rotary_encoder/rotary_encoder.h" #include "esphome/components/rotary_encoder/rotary_encoder.h"
#endif // USE_LVGL_ROTARY_ENCODER #endif // USE_LVGL_ROTARY_ENCODER

View File

@ -271,6 +271,7 @@ async def set_obj_properties(w: Widget, config):
"""Generate a list of C++ statements to apply properties to an lv_obj_t""" """Generate a list of C++ statements to apply properties to an lv_obj_t"""
if layout := config.get(CONF_LAYOUT): if layout := config.get(CONF_LAYOUT):
layout_type: str = layout[CONF_TYPE] layout_type: str = layout[CONF_TYPE]
add_lv_use(layout_type)
lv_obj.set_layout(w.obj, literal(f"LV_LAYOUT_{layout_type.upper()}")) lv_obj.set_layout(w.obj, literal(f"LV_LAYOUT_{layout_type.upper()}"))
if layout_type == TYPE_GRID: if layout_type == TYPE_GRID:
wid = config[CONF_ID] wid = config[CONF_ID]
@ -334,7 +335,7 @@ async def set_obj_properties(w: Widget, config):
for key, value in states.items(): for key, value in states.items():
if isinstance(value, cv.Lambda): if isinstance(value, cv.Lambda):
lambs[key] = value lambs[key] = value
elif value == "true": elif value:
adds.add(key) adds.add(key)
else: else:
clears.add(key) clears.add(key)