mirror of
https://github.com/esphome/esphome.git
synced 2026-05-28 13:37:24 +08:00
[lvgl] Fix args for lambda in set_rotation action (#15555)
This commit is contained in:
@@ -2,6 +2,7 @@ from collections.abc import Callable
|
|||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from esphome import automation
|
from esphome import automation
|
||||||
|
from esphome.automation import StatelessLambdaAction
|
||||||
import esphome.codegen as cg
|
import esphome.codegen as cg
|
||||||
from esphome.components.display import validate_rotation
|
from esphome.components.display import validate_rotation
|
||||||
import esphome.config_validation as cv
|
import esphome.config_validation as cv
|
||||||
@@ -201,7 +202,7 @@ def _validate_rotation(value):
|
|||||||
|
|
||||||
@automation.register_action(
|
@automation.register_action(
|
||||||
"lvgl.display.set_rotation",
|
"lvgl.display.set_rotation",
|
||||||
ObjUpdateAction,
|
StatelessLambdaAction,
|
||||||
cv.maybe_simple_value(
|
cv.maybe_simple_value(
|
||||||
LVGL_SCHEMA.extend(
|
LVGL_SCHEMA.extend(
|
||||||
{
|
{
|
||||||
@@ -214,8 +215,7 @@ def _validate_rotation(value):
|
|||||||
)
|
)
|
||||||
async def lvgl_set_rotation(config, action_id, template_arg, args):
|
async def lvgl_set_rotation(config, action_id, template_arg, args):
|
||||||
lv_comp = await cg.get_variable(config[CONF_LVGL_ID])
|
lv_comp = await cg.get_variable(config[CONF_LVGL_ID])
|
||||||
async with LambdaContext() as context:
|
async with LambdaContext(args, where=action_id) as context:
|
||||||
add_line_marks(where=action_id)
|
|
||||||
lv_add(lv_comp.set_rotation(config[CONF_ROTATION]))
|
lv_add(lv_comp.set_rotation(config[CONF_ROTATION]))
|
||||||
return cg.new_Pvariable(action_id, template_arg, await context.get_lambda())
|
return cg.new_Pvariable(action_id, template_arg, await context.get_lambda())
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ from esphome import automation
|
|||||||
import esphome.codegen as cg
|
import esphome.codegen as cg
|
||||||
import esphome.config_validation as cv
|
import esphome.config_validation as cv
|
||||||
from esphome.const import (
|
from esphome.const import (
|
||||||
|
CONF_BUTTON,
|
||||||
CONF_ID,
|
CONF_ID,
|
||||||
CONF_INDEX,
|
CONF_INDEX,
|
||||||
CONF_ITEMS,
|
CONF_ITEMS,
|
||||||
@@ -73,7 +74,7 @@ class TabviewType(WidgetType):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def get_uses(self):
|
def get_uses(self):
|
||||||
return CONF_BUTTONMATRIX, TYPE_FLEX
|
return CONF_BUTTONMATRIX, TYPE_FLEX, CONF_BUTTON
|
||||||
|
|
||||||
async def to_code(self, w: Widget, config: dict):
|
async def to_code(self, w: Widget, config: dict):
|
||||||
await w.set_property(
|
await w.set_property(
|
||||||
|
|||||||
@@ -194,6 +194,7 @@ lvgl:
|
|||||||
text: "Close"
|
text: "Close"
|
||||||
on_click:
|
on_click:
|
||||||
then:
|
then:
|
||||||
|
- lvgl.display.set_rotation: 0
|
||||||
- lvgl.widget.hide: message_box
|
- lvgl.widget.hide: message_box
|
||||||
- lvgl.style.update:
|
- lvgl.style.update:
|
||||||
id: style_test
|
id: style_test
|
||||||
|
|||||||
Reference in New Issue
Block a user