Merge remote-tracking branch 'origin/dev' into nrf52_core

This commit is contained in:
Tomasz Duda 2024-08-07 17:19:41 +02:00
commit 53d1538bfd
50 changed files with 272 additions and 309 deletions

View file

@ -1,10 +1,8 @@
import esphome.codegen as cg
import esphome.config_validation as cv
from esphome.cpp_generator import MockObjClass
from esphome.cpp_helpers import setup_entity
from esphome import automation, core from esphome import automation, core
from esphome.automation import Condition, maybe_simple_id from esphome.automation import Condition, maybe_simple_id
import esphome.codegen as cg
from esphome.components import mqtt, web_server from esphome.components import mqtt, web_server
import esphome.config_validation as cv
from esphome.const import ( from esphome.const import (
CONF_DELAY, CONF_DELAY,
CONF_DEVICE_CLASS, CONF_DEVICE_CLASS,
@ -16,6 +14,7 @@ from esphome.const import (
CONF_INVERTED, CONF_INVERTED,
CONF_MAX_LENGTH, CONF_MAX_LENGTH,
CONF_MIN_LENGTH, CONF_MIN_LENGTH,
CONF_MQTT_ID,
CONF_ON_CLICK, CONF_ON_CLICK,
CONF_ON_DOUBLE_CLICK, CONF_ON_DOUBLE_CLICK,
CONF_ON_MULTI_CLICK, CONF_ON_MULTI_CLICK,
@ -26,7 +25,6 @@ from esphome.const import (
CONF_STATE, CONF_STATE,
CONF_TIMING, CONF_TIMING,
CONF_TRIGGER_ID, CONF_TRIGGER_ID,
CONF_MQTT_ID,
CONF_WEB_SERVER_ID, CONF_WEB_SERVER_ID,
DEVICE_CLASS_BATTERY, DEVICE_CLASS_BATTERY,
DEVICE_CLASS_BATTERY_CHARGING, DEVICE_CLASS_BATTERY_CHARGING,
@ -59,6 +57,8 @@ from esphome.const import (
DEVICE_CLASS_WINDOW, DEVICE_CLASS_WINDOW,
) )
from esphome.core import CORE, coroutine_with_priority from esphome.core import CORE, coroutine_with_priority
from esphome.cpp_generator import MockObjClass
from esphome.cpp_helpers import setup_entity
from esphome.util import Registry from esphome.util import Registry
CODEOWNERS = ["@esphome/core"] CODEOWNERS = ["@esphome/core"]

View file

@ -1,16 +1,16 @@
import esphome.codegen as cg
import esphome.config_validation as cv
from esphome import automation from esphome import automation
from esphome.automation import maybe_simple_id from esphome.automation import maybe_simple_id
import esphome.codegen as cg
from esphome.components import mqtt, web_server from esphome.components import mqtt, web_server
import esphome.config_validation as cv
from esphome.const import ( from esphome.const import (
CONF_DEVICE_CLASS, CONF_DEVICE_CLASS,
CONF_ENTITY_CATEGORY, CONF_ENTITY_CATEGORY,
CONF_ICON, CONF_ICON,
CONF_ID, CONF_ID,
CONF_MQTT_ID,
CONF_ON_PRESS, CONF_ON_PRESS,
CONF_TRIGGER_ID, CONF_TRIGGER_ID,
CONF_MQTT_ID,
CONF_WEB_SERVER_ID, CONF_WEB_SERVER_ID,
DEVICE_CLASS_EMPTY, DEVICE_CLASS_EMPTY,
DEVICE_CLASS_IDENTIFY, DEVICE_CLASS_IDENTIFY,
@ -18,8 +18,8 @@ from esphome.const import (
DEVICE_CLASS_UPDATE, DEVICE_CLASS_UPDATE,
) )
from esphome.core import CORE, coroutine_with_priority from esphome.core import CORE, coroutine_with_priority
from esphome.cpp_helpers import setup_entity
from esphome.cpp_generator import MockObjClass from esphome.cpp_generator import MockObjClass
from esphome.cpp_helpers import setup_entity
CODEOWNERS = ["@esphome/core"] CODEOWNERS = ["@esphome/core"]
IS_PLATFORM_COMPONENT = True IS_PLATFORM_COMPONENT = True

View file

@ -1,8 +1,7 @@
import esphome.codegen as cg
import esphome.config_validation as cv
from esphome.cpp_helpers import setup_entity
from esphome import automation from esphome import automation
import esphome.codegen as cg
from esphome.components import mqtt, web_server from esphome.components import mqtt, web_server
import esphome.config_validation as cv
from esphome.const import ( from esphome.const import (
CONF_ACTION_STATE_TOPIC, CONF_ACTION_STATE_TOPIC,
CONF_AWAY, CONF_AWAY,
@ -21,6 +20,7 @@ from esphome.const import (
CONF_MODE, CONF_MODE,
CONF_MODE_COMMAND_TOPIC, CONF_MODE_COMMAND_TOPIC,
CONF_MODE_STATE_TOPIC, CONF_MODE_STATE_TOPIC,
CONF_MQTT_ID,
CONF_ON_CONTROL, CONF_ON_CONTROL,
CONF_ON_STATE, CONF_ON_STATE,
CONF_PRESET, CONF_PRESET,
@ -33,20 +33,20 @@ from esphome.const import (
CONF_TARGET_HUMIDITY_STATE_TOPIC, CONF_TARGET_HUMIDITY_STATE_TOPIC,
CONF_TARGET_TEMPERATURE, CONF_TARGET_TEMPERATURE,
CONF_TARGET_TEMPERATURE_COMMAND_TOPIC, CONF_TARGET_TEMPERATURE_COMMAND_TOPIC,
CONF_TARGET_TEMPERATURE_STATE_TOPIC,
CONF_TARGET_TEMPERATURE_HIGH, CONF_TARGET_TEMPERATURE_HIGH,
CONF_TARGET_TEMPERATURE_HIGH_COMMAND_TOPIC, CONF_TARGET_TEMPERATURE_HIGH_COMMAND_TOPIC,
CONF_TARGET_TEMPERATURE_HIGH_STATE_TOPIC, CONF_TARGET_TEMPERATURE_HIGH_STATE_TOPIC,
CONF_TARGET_TEMPERATURE_LOW, CONF_TARGET_TEMPERATURE_LOW,
CONF_TARGET_TEMPERATURE_LOW_COMMAND_TOPIC, CONF_TARGET_TEMPERATURE_LOW_COMMAND_TOPIC,
CONF_TARGET_TEMPERATURE_LOW_STATE_TOPIC, CONF_TARGET_TEMPERATURE_LOW_STATE_TOPIC,
CONF_TARGET_TEMPERATURE_STATE_TOPIC,
CONF_TEMPERATURE_STEP, CONF_TEMPERATURE_STEP,
CONF_TRIGGER_ID, CONF_TRIGGER_ID,
CONF_VISUAL, CONF_VISUAL,
CONF_MQTT_ID,
CONF_WEB_SERVER_ID, CONF_WEB_SERVER_ID,
) )
from esphome.core import CORE, coroutine_with_priority from esphome.core import CORE, coroutine_with_priority
from esphome.cpp_helpers import setup_entity
IS_PLATFORM_COMPONENT = True IS_PLATFORM_COMPONENT = True

View file

@ -1,23 +1,23 @@
import esphome.codegen as cg
import esphome.config_validation as cv
from esphome import automation from esphome import automation
from esphome.automation import maybe_simple_id, Condition from esphome.automation import Condition, maybe_simple_id
import esphome.codegen as cg
from esphome.components import mqtt, web_server from esphome.components import mqtt, web_server
import esphome.config_validation as cv
from esphome.const import ( from esphome.const import (
CONF_ID,
CONF_DEVICE_CLASS, CONF_DEVICE_CLASS,
CONF_STATE, CONF_ID,
CONF_MQTT_ID,
CONF_ON_OPEN, CONF_ON_OPEN,
CONF_POSITION, CONF_POSITION,
CONF_POSITION_COMMAND_TOPIC, CONF_POSITION_COMMAND_TOPIC,
CONF_POSITION_STATE_TOPIC, CONF_POSITION_STATE_TOPIC,
CONF_STATE,
CONF_STOP,
CONF_TILT, CONF_TILT,
CONF_TILT_COMMAND_TOPIC, CONF_TILT_COMMAND_TOPIC,
CONF_TILT_STATE_TOPIC, CONF_TILT_STATE_TOPIC,
CONF_STOP,
CONF_MQTT_ID,
CONF_WEB_SERVER_ID,
CONF_TRIGGER_ID, CONF_TRIGGER_ID,
CONF_WEB_SERVER_ID,
DEVICE_CLASS_AWNING, DEVICE_CLASS_AWNING,
DEVICE_CLASS_BLIND, DEVICE_CLASS_BLIND,
DEVICE_CLASS_CURTAIN, DEVICE_CLASS_CURTAIN,

View file

@ -5,13 +5,17 @@ namespace cst226 {
void CST226Touchscreen::setup() { void CST226Touchscreen::setup() {
esph_log_config(TAG, "Setting up CST226 Touchscreen..."); esph_log_config(TAG, "Setting up CST226 Touchscreen...");
this->reset_pin_->setup(); if (this->reset_pin_ != nullptr) {
this->reset_pin_->digital_write(true); this->reset_pin_->setup();
delay(5); this->reset_pin_->digital_write(true);
this->reset_pin_->digital_write(false); delay(5);
delay(5); this->reset_pin_->digital_write(false);
this->reset_pin_->digital_write(true); delay(5);
this->set_timeout(30, [this] { this->continue_setup_(); }); this->reset_pin_->digital_write(true);
this->set_timeout(30, [this] { this->continue_setup_(); });
} else {
this->continue_setup_();
}
} }
void CST226Touchscreen::update_touches() { void CST226Touchscreen::update_touches() {

View file

@ -35,7 +35,7 @@ class CST226Touchscreen : public touchscreen::Touchscreen, public i2c::I2CDevice
void continue_setup_(); void continue_setup_();
InternalGPIOPin *interrupt_pin_{}; InternalGPIOPin *interrupt_pin_{};
GPIOPin *reset_pin_{NULL_PIN}; GPIOPin *reset_pin_{};
uint8_t chip_id_{}; uint8_t chip_id_{};
bool setup_complete_{}; bool setup_complete_{};
}; };

View file

@ -1,32 +1,30 @@
import esphome.codegen as cg
import esphome.config_validation as cv
from esphome import automation from esphome import automation
from esphome.components import mqtt, web_server, time import esphome.codegen as cg
from esphome.components import mqtt, time, web_server
import esphome.config_validation as cv
from esphome.const import ( from esphome.const import (
CONF_DATE,
CONF_DATETIME,
CONF_DAY,
CONF_HOUR,
CONF_ID, CONF_ID,
CONF_MINUTE,
CONF_MONTH,
CONF_MQTT_ID,
CONF_ON_TIME, CONF_ON_TIME,
CONF_ON_VALUE, CONF_ON_VALUE,
CONF_SECOND,
CONF_TIME,
CONF_TIME_ID, CONF_TIME_ID,
CONF_TRIGGER_ID, CONF_TRIGGER_ID,
CONF_TYPE, CONF_TYPE,
CONF_MQTT_ID,
CONF_WEB_SERVER_ID, CONF_WEB_SERVER_ID,
CONF_DATE,
CONF_DATETIME,
CONF_TIME,
CONF_YEAR, CONF_YEAR,
CONF_MONTH,
CONF_DAY,
CONF_SECOND,
CONF_HOUR,
CONF_MINUTE,
) )
from esphome.core import CORE, coroutine_with_priority from esphome.core import CORE, coroutine_with_priority
from esphome.cpp_generator import MockObjClass from esphome.cpp_generator import MockObjClass
from esphome.cpp_helpers import setup_entity from esphome.cpp_helpers import setup_entity
CODEOWNERS = ["@rfdarter", "@jesserockz"] CODEOWNERS = ["@rfdarter", "@jesserockz"]
DEPENDENCIES = ["time"] DEPENDENCIES = ["time"]

View file

@ -1,23 +1,26 @@
import re import re
import esphome.codegen as cg
import esphome.config_validation as cv
from esphome import automation, core from esphome import automation, core
from esphome.automation import maybe_simple_id
import esphome.codegen as cg
from esphome.components.number import Number
from esphome.components.select import Select
from esphome.components.switch import Switch
import esphome.config_validation as cv
from esphome.const import ( from esphome.const import (
CONF_ID, CONF_ACTIVE,
CONF_TYPE,
CONF_TRIGGER_ID,
CONF_ON_VALUE,
CONF_COMMAND, CONF_COMMAND,
CONF_CUSTOM, CONF_CUSTOM,
CONF_NUMBER,
CONF_FORMAT, CONF_FORMAT,
CONF_ID,
CONF_ITEMS,
CONF_MODE, CONF_MODE,
CONF_ACTIVE, CONF_NUMBER,
CONF_ON_VALUE,
CONF_TEXT,
CONF_TRIGGER_ID,
CONF_TYPE,
) )
from esphome.automation import maybe_simple_id
from esphome.components.select import Select
from esphome.components.number import Number
from esphome.components.switch import Switch
CODEOWNERS = ["@numo68"] CODEOWNERS = ["@numo68"]
@ -29,10 +32,8 @@ CONF_JOYSTICK = "joystick"
CONF_LABEL = "label" CONF_LABEL = "label"
CONF_MENU = "menu" CONF_MENU = "menu"
CONF_BACK = "back" CONF_BACK = "back"
CONF_TEXT = "text"
CONF_SELECT = "select" CONF_SELECT = "select"
CONF_SWITCH = "switch" CONF_SWITCH = "switch"
CONF_ITEMS = "items"
CONF_ON_TEXT = "on_text" CONF_ON_TEXT = "on_text"
CONF_OFF_TEXT = "off_text" CONF_OFF_TEXT = "off_text"
CONF_VALUE_LAMBDA = "value_lambda" CONF_VALUE_LAMBDA = "value_lambda"

View file

@ -1,24 +1,24 @@
import esphome.codegen as cg
import esphome.config_validation as cv
from esphome import automation from esphome import automation
import esphome.codegen as cg
from esphome.components import mqtt from esphome.components import mqtt
import esphome.config_validation as cv
from esphome.const import ( from esphome.const import (
CONF_DEVICE_CLASS, CONF_DEVICE_CLASS,
CONF_ENTITY_CATEGORY, CONF_ENTITY_CATEGORY,
CONF_EVENT_TYPE,
CONF_ICON, CONF_ICON,
CONF_ID, CONF_ID,
CONF_MQTT_ID,
CONF_ON_EVENT, CONF_ON_EVENT,
CONF_TRIGGER_ID, CONF_TRIGGER_ID,
CONF_MQTT_ID,
CONF_EVENT_TYPE,
DEVICE_CLASS_BUTTON, DEVICE_CLASS_BUTTON,
DEVICE_CLASS_DOORBELL, DEVICE_CLASS_DOORBELL,
DEVICE_CLASS_EMPTY, DEVICE_CLASS_EMPTY,
DEVICE_CLASS_MOTION, DEVICE_CLASS_MOTION,
) )
from esphome.core import CORE, coroutine_with_priority from esphome.core import CORE, coroutine_with_priority
from esphome.cpp_helpers import setup_entity
from esphome.cpp_generator import MockObjClass from esphome.cpp_generator import MockObjClass
from esphome.cpp_helpers import setup_entity
CODEOWNERS = ["@nohat"] CODEOWNERS = ["@nohat"]
IS_PLATFORM_COMPONENT = True IS_PLATFORM_COMPONENT = True

View file

@ -1,31 +1,31 @@
import esphome.codegen as cg
import esphome.config_validation as cv
from esphome import automation from esphome import automation
from esphome.automation import maybe_simple_id from esphome.automation import maybe_simple_id
import esphome.codegen as cg
from esphome.components import mqtt, web_server from esphome.components import mqtt, web_server
import esphome.config_validation as cv
from esphome.const import ( from esphome.const import (
CONF_DIRECTION,
CONF_ID, CONF_ID,
CONF_MQTT_ID, CONF_MQTT_ID,
CONF_WEB_SERVER_ID,
CONF_OSCILLATING,
CONF_OSCILLATION_COMMAND_TOPIC,
CONF_OSCILLATION_STATE_TOPIC,
CONF_SPEED,
CONF_SPEED_LEVEL_COMMAND_TOPIC,
CONF_SPEED_LEVEL_STATE_TOPIC,
CONF_SPEED_COMMAND_TOPIC,
CONF_SPEED_STATE_TOPIC,
CONF_OFF_SPEED_CYCLE, CONF_OFF_SPEED_CYCLE,
CONF_ON_DIRECTION_SET, CONF_ON_DIRECTION_SET,
CONF_ON_OSCILLATING_SET, CONF_ON_OSCILLATING_SET,
CONF_ON_PRESET_SET,
CONF_ON_SPEED_SET, CONF_ON_SPEED_SET,
CONF_ON_STATE, CONF_ON_STATE,
CONF_ON_TURN_OFF, CONF_ON_TURN_OFF,
CONF_ON_TURN_ON, CONF_ON_TURN_ON,
CONF_ON_PRESET_SET, CONF_OSCILLATING,
CONF_TRIGGER_ID, CONF_OSCILLATION_COMMAND_TOPIC,
CONF_DIRECTION, CONF_OSCILLATION_STATE_TOPIC,
CONF_RESTORE_MODE, CONF_RESTORE_MODE,
CONF_SPEED,
CONF_SPEED_COMMAND_TOPIC,
CONF_SPEED_LEVEL_COMMAND_TOPIC,
CONF_SPEED_LEVEL_STATE_TOPIC,
CONF_SPEED_STATE_TOPIC,
CONF_TRIGGER_ID,
CONF_WEB_SERVER_ID,
) )
from esphome.core import CORE, coroutine_with_priority from esphome.core import CORE, coroutine_with_priority
from esphome.cpp_helpers import setup_entity from esphome.cpp_helpers import setup_entity

View file

@ -10,12 +10,12 @@ import esphome.config_validation as cv
from esphome.const import ( from esphome.const import (
CONF_BACKGROUND_COLOR, CONF_BACKGROUND_COLOR,
CONF_DISPLAY, CONF_DISPLAY,
CONF_FONT,
CONF_FOREGROUND_COLOR, CONF_FOREGROUND_COLOR,
CONF_ID, CONF_ID,
CONF_TRIGGER_ID, CONF_TRIGGER_ID,
) )
CONF_FONT = "font"
CONF_MENU_ITEM_VALUE = "menu_item_value" CONF_MENU_ITEM_VALUE = "menu_item_value"
CONF_ON_REDRAW = "on_redraw" CONF_ON_REDRAW = "on_redraw"

View file

@ -1,8 +1,9 @@
import esphome.codegen as cg
import esphome.config_validation as cv
import esphome.automation as auto import esphome.automation as auto
import esphome.codegen as cg
from esphome.components import mqtt, power_supply, web_server from esphome.components import mqtt, power_supply, web_server
import esphome.config_validation as cv
from esphome.const import ( from esphome.const import (
CONF_COLD_WHITE_COLOR_TEMPERATURE,
CONF_COLOR_CORRECT, CONF_COLOR_CORRECT,
CONF_DEFAULT_TRANSITION_LENGTH, CONF_DEFAULT_TRANSITION_LENGTH,
CONF_EFFECTS, CONF_EFFECTS,
@ -10,36 +11,36 @@ from esphome.const import (
CONF_GAMMA_CORRECT, CONF_GAMMA_CORRECT,
CONF_ID, CONF_ID,
CONF_MQTT_ID, CONF_MQTT_ID,
CONF_WEB_SERVER_ID, CONF_ON_STATE,
CONF_POWER_SUPPLY,
CONF_RESTORE_MODE,
CONF_ON_TURN_OFF, CONF_ON_TURN_OFF,
CONF_ON_TURN_ON, CONF_ON_TURN_ON,
CONF_ON_STATE, CONF_POWER_SUPPLY,
CONF_RESTORE_MODE,
CONF_TRIGGER_ID, CONF_TRIGGER_ID,
CONF_COLD_WHITE_COLOR_TEMPERATURE,
CONF_WARM_WHITE_COLOR_TEMPERATURE, CONF_WARM_WHITE_COLOR_TEMPERATURE,
CONF_WEB_SERVER_ID,
) )
from esphome.core import coroutine_with_priority from esphome.core import coroutine_with_priority
from esphome.cpp_helpers import setup_entity from esphome.cpp_helpers import setup_entity
from .automation import light_control_to_code # noqa from .automation import light_control_to_code # noqa
from .effects import ( from .effects import (
validate_effects, ADDRESSABLE_EFFECTS,
BINARY_EFFECTS, BINARY_EFFECTS,
EFFECTS_REGISTRY,
MONOCHROMATIC_EFFECTS, MONOCHROMATIC_EFFECTS,
RGB_EFFECTS, RGB_EFFECTS,
ADDRESSABLE_EFFECTS, validate_effects,
EFFECTS_REGISTRY,
) )
from .types import ( # noqa from .types import ( # noqa
LightState,
AddressableLightState,
light_ns,
LightOutput,
AddressableLight, AddressableLight,
LightTurnOnTrigger, AddressableLightState,
LightTurnOffTrigger, LightOutput,
LightState,
LightStateTrigger, LightStateTrigger,
LightTurnOffTrigger,
LightTurnOnTrigger,
light_ns,
) )
CODEOWNERS = ["@esphome/core"] CODEOWNERS = ["@esphome/core"]

View file

@ -1,14 +1,14 @@
import esphome.codegen as cg
import esphome.config_validation as cv
from esphome import automation from esphome import automation
from esphome.automation import Condition, maybe_simple_id from esphome.automation import Condition, maybe_simple_id
import esphome.codegen as cg
from esphome.components import mqtt, web_server from esphome.components import mqtt, web_server
import esphome.config_validation as cv
from esphome.const import ( from esphome.const import (
CONF_ID, CONF_ID,
CONF_MQTT_ID,
CONF_ON_LOCK, CONF_ON_LOCK,
CONF_ON_UNLOCK, CONF_ON_UNLOCK,
CONF_TRIGGER_ID, CONF_TRIGGER_ID,
CONF_MQTT_ID,
CONF_WEB_SERVER_ID, CONF_WEB_SERVER_ID,
) )
from esphome.core import CORE, coroutine_with_priority from esphome.core import CORE, coroutine_with_priority

View file

@ -23,9 +23,9 @@ from esphome.helpers import write_file_if_changed
from . import defines as df, helpers, lv_validation as lvalid from . import defines as df, helpers, lv_validation as lvalid
from .automation import disp_update, update_to_code from .automation import disp_update, update_to_code
from .defines import CONF_SKIP from .defines import CONF_SKIP
from .encoders import ENCODERS_CONFIG, encoders_to_code
from .lv_validation import lv_bool, lv_images_used from .lv_validation import lv_bool, lv_images_used
from .lvcode import LvContext, LvglComponent from .lvcode import LvContext, LvglComponent
from .rotary_encoders import ROTARY_ENCODER_CONFIG, rotary_encoders_to_code
from .schemas import ( from .schemas import (
DISP_BG_SCHEMA, DISP_BG_SCHEMA,
FLEX_OBJ_SCHEMA, FLEX_OBJ_SCHEMA,
@ -256,7 +256,7 @@ async def to_code(config):
async with LvContext(lv_component): async with LvContext(lv_component):
await touchscreens_to_code(lv_component, config) await touchscreens_to_code(lv_component, config)
await rotary_encoders_to_code(lv_component, config) await encoders_to_code(lv_component, config)
await theme_to_code(config) await theme_to_code(config)
await styles_to_code(config) await styles_to_code(config)
await set_obj_properties(lv_scr_act, config) await set_obj_properties(lv_scr_act, config)
@ -336,7 +336,7 @@ CONFIG_SCHEMA = (
{cv.Optional(name): obj_schema(w) for name, w in WIDGET_TYPES.items()} {cv.Optional(name): obj_schema(w) for name, w in WIDGET_TYPES.items()}
), ),
cv.GenerateID(df.CONF_TOUCHSCREENS): touchscreen_schema, cv.GenerateID(df.CONF_TOUCHSCREENS): touchscreen_schema,
cv.GenerateID(df.CONF_ROTARY_ENCODERS): ROTARY_ENCODER_CONFIG, cv.GenerateID(df.CONF_ENCODERS): ENCODERS_CONFIG,
} }
) )
.extend(DISP_BG_SCHEMA) .extend(DISP_BG_SCHEMA)

View file

@ -5,6 +5,7 @@ Constants already defined in esphome.const are not duplicated here and must be i
""" """
from esphome import codegen as cg, config_validation as cv from esphome import codegen as cg, config_validation as cv
from esphome.const import CONF_ITEMS
from esphome.core import ID, Lambda from esphome.core import ID, Lambda
from esphome.cpp_generator import MockObj from esphome.cpp_generator import MockObj
from esphome.cpp_types import uint32 from esphome.cpp_types import uint32
@ -115,7 +116,6 @@ CONF_SCROLLBAR = "scrollbar"
CONF_INDICATOR = "indicator" CONF_INDICATOR = "indicator"
CONF_KNOB = "knob" CONF_KNOB = "knob"
CONF_SELECTED = "selected" CONF_SELECTED = "selected"
CONF_ITEMS = "items"
CONF_TICKS = "ticks" CONF_TICKS = "ticks"
CONF_CURSOR = "cursor" CONF_CURSOR = "cursor"
CONF_TEXTAREA_PLACEHOLDER = "textarea_placeholder" CONF_TEXTAREA_PLACEHOLDER = "textarea_placeholder"
@ -388,6 +388,7 @@ CONF_DEFAULT = "default"
CONF_DEFAULT_FONT = "default_font" CONF_DEFAULT_FONT = "default_font"
CONF_DIR = "dir" CONF_DIR = "dir"
CONF_DISPLAYS = "displays" CONF_DISPLAYS = "displays"
CONF_ENCODERS = "encoders"
CONF_END_ANGLE = "end_angle" CONF_END_ANGLE = "end_angle"
CONF_END_VALUE = "end_value" CONF_END_VALUE = "end_value"
CONF_ENTER_BUTTON = "enter_button" CONF_ENTER_BUTTON = "enter_button"
@ -441,7 +442,6 @@ CONF_RECOLOR = "recolor"
CONF_RIGHT_BUTTON = "right_button" CONF_RIGHT_BUTTON = "right_button"
CONF_ROLLOVER = "rollover" CONF_ROLLOVER = "rollover"
CONF_ROOT_BACK_BTN = "root_back_btn" CONF_ROOT_BACK_BTN = "root_back_btn"
CONF_ROTARY_ENCODERS = "rotary_encoders"
CONF_ROWS = "rows" CONF_ROWS = "rows"
CONF_SCALE_LINES = "scale_lines" CONF_SCALE_LINES = "scale_lines"
CONF_SCROLLBAR_MODE = "scrollbar_mode" CONF_SCROLLBAR_MODE = "scrollbar_mode"
@ -460,7 +460,6 @@ CONF_SKIP = "skip"
CONF_SYMBOL = "symbol" CONF_SYMBOL = "symbol"
CONF_TAB_ID = "tab_id" CONF_TAB_ID = "tab_id"
CONF_TABS = "tabs" CONF_TABS = "tabs"
CONF_TEXT = "text"
CONF_TILE = "tile" CONF_TILE = "tile"
CONF_TILE_ID = "tile_id" CONF_TILE_ID = "tile_id"
CONF_TILES = "tiles" CONF_TILES = "tiles"

View file

@ -5,25 +5,26 @@ import esphome.config_validation as cv
from esphome.const import CONF_GROUP, CONF_ID, CONF_SENSOR from esphome.const import CONF_GROUP, CONF_ID, CONF_SENSOR
from .defines import ( from .defines import (
CONF_ENCODERS,
CONF_ENTER_BUTTON, CONF_ENTER_BUTTON,
CONF_LEFT_BUTTON, CONF_LEFT_BUTTON,
CONF_LONG_PRESS_REPEAT_TIME, CONF_LONG_PRESS_REPEAT_TIME,
CONF_LONG_PRESS_TIME, CONF_LONG_PRESS_TIME,
CONF_RIGHT_BUTTON, CONF_RIGHT_BUTTON,
CONF_ROTARY_ENCODERS,
) )
from .helpers import lvgl_components_required from .helpers import lvgl_components_required, requires_component
from .lvcode import lv, lv_add, lv_expr from .lvcode import lv, lv_add, lv_assign, lv_expr, lv_Pvariable
from .schemas import ENCODER_SCHEMA from .schemas import ENCODER_SCHEMA
from .types import lv_indev_type_t from .types import lv_group_t, lv_indev_type_t
from .widgets import add_group
ROTARY_ENCODER_CONFIG = cv.ensure_list( ENCODERS_CONFIG = cv.ensure_list(
ENCODER_SCHEMA.extend( ENCODER_SCHEMA.extend(
{ {
cv.Required(CONF_ENTER_BUTTON): cv.use_id(BinarySensor), cv.Required(CONF_ENTER_BUTTON): cv.use_id(BinarySensor),
cv.Required(CONF_SENSOR): cv.Any( cv.Required(CONF_SENSOR): cv.Any(
cv.use_id(RotaryEncoderSensor), cv.All(
cv.use_id(RotaryEncoderSensor), requires_component("rotary_encoder")
),
cv.Schema( cv.Schema(
{ {
cv.Required(CONF_LEFT_BUTTON): cv.use_id(BinarySensor), cv.Required(CONF_LEFT_BUTTON): cv.use_id(BinarySensor),
@ -36,10 +37,9 @@ ROTARY_ENCODER_CONFIG = cv.ensure_list(
) )
async def rotary_encoders_to_code(var, config): async def encoders_to_code(var, config):
for enc_conf in config.get(CONF_ROTARY_ENCODERS, ()): for enc_conf in config.get(CONF_ENCODERS, ()):
lvgl_components_required.add("KEY_LISTENER") lvgl_components_required.add("KEY_LISTENER")
lvgl_components_required.add("ROTARY_ENCODER")
lpt = enc_conf[CONF_LONG_PRESS_TIME].total_milliseconds lpt = enc_conf[CONF_LONG_PRESS_TIME].total_milliseconds
lprt = enc_conf[CONF_LONG_PRESS_REPEAT_TIME].total_milliseconds lprt = enc_conf[CONF_LONG_PRESS_REPEAT_TIME].total_milliseconds
listener = cg.new_Pvariable( listener = cg.new_Pvariable(
@ -57,7 +57,9 @@ async def rotary_encoders_to_code(var, config):
lv_add(listener.set_sensor(sensor_config)) lv_add(listener.set_sensor(sensor_config))
b_sensor = await cg.get_variable(enc_conf[CONF_ENTER_BUTTON]) b_sensor = await cg.get_variable(enc_conf[CONF_ENTER_BUTTON])
cg.add(listener.set_enter_button(b_sensor)) cg.add(listener.set_enter_button(b_sensor))
if group := add_group(enc_conf.get(CONF_GROUP)): if group := enc_conf.get(CONF_GROUP):
group = lv_Pvariable(lv_group_t, group)
lv_assign(group, lv_expr.group_create())
lv.indev_set_group(lv_expr.indev_drv_register(listener.get_drv()), group) lv.indev_set_group(lv_expr.indev_drv_register(listener.get_drv()), group)
else: else:
lv.indev_drv_register(listener.get_drv()) lv.indev_drv_register(listener.get_drv())

View file

@ -127,7 +127,7 @@ void LVTouchListener::update(const touchscreen::TouchPoints_t &tpoints) {
} }
#endif // USE_LVGL_TOUCHSCREEN #endif // USE_LVGL_TOUCHSCREEN
#ifdef USE_LVGL_ROTARY_ENCODER #ifdef USE_LVGL_KEY_LISTENER
LVEncoderListener::LVEncoderListener(lv_indev_type_t type, uint16_t lpt, uint16_t lprt) { LVEncoderListener::LVEncoderListener(lv_indev_type_t type, uint16_t lpt, uint16_t lprt) {
lv_indev_drv_init(&this->drv_); lv_indev_drv_init(&this->drv_);
this->drv_.type = type; this->drv_.type = type;
@ -143,7 +143,7 @@ LVEncoderListener::LVEncoderListener(lv_indev_type_t type, uint16_t lpt, uint16_
data->continue_reading = false; data->continue_reading = false;
}; };
} }
#endif // USE_LVGL_ROTARY_ENCODER #endif // USE_LVGL_KEY_LISTENER
#ifdef USE_LVGL_BUTTONMATRIX #ifdef USE_LVGL_BUTTONMATRIX
void LvButtonMatrixType::set_obj(lv_obj_t *lv_obj) { void LvButtonMatrixType::set_obj(lv_obj_t *lv_obj) {

View file

@ -1,6 +1,13 @@
#pragma once #pragma once
#include "esphome/core/defines.h" #include "esphome/core/defines.h"
#ifdef USE_LVGL_BINARY_SENSOR
#include "esphome/components/binary_sensor/binary_sensor.h"
#endif // USE_LVGL_BINARY_SENSOR
#ifdef USE_LVGL_ROTARY_ENCODER
#include "esphome/components/rotary_encoder/rotary_encoder.h"
#endif // USE_LVGL_ROTARY_ENCODER
// required for clang-tidy // required for clang-tidy
#ifndef LV_CONF_H #ifndef LV_CONF_H
#define LV_CONF_SKIP 1 // NOLINT #define LV_CONF_SKIP 1 // NOLINT
@ -12,12 +19,7 @@
#include "esphome/core/log.h" #include "esphome/core/log.h"
#include <lvgl.h> #include <lvgl.h>
#include <vector> #include <vector>
#include <map>
#ifdef USE_LVGL_ROTARY_ENCODER
#include "esphome/components/binary_sensor/binary_sensor.h"
#include "esphome/components/rotary_encoder/rotary_encoder.h"
#endif // USE_LVGL_ROTARY_ENCODER
#ifdef USE_LVGL_IMAGE #ifdef USE_LVGL_IMAGE
#include "esphome/components/image/image.h" #include "esphome/components/image/image.h"
#endif // USE_LVGL_IMAGE #endif // USE_LVGL_IMAGE
@ -202,7 +204,7 @@ class LVTouchListener : public touchscreen::TouchListener, public Parented<LvglC
}; };
#endif // USE_LVGL_TOUCHSCREEN #endif // USE_LVGL_TOUCHSCREEN
#ifdef USE_LVGL_ROTARY_ENCODER #ifdef USE_LVGL_KEY_LISTENER
class LVEncoderListener : public Parented<LvglComponent> { class LVEncoderListener : public Parented<LvglComponent> {
public: public:
LVEncoderListener(lv_indev_type_t type, uint16_t lpt, uint16_t lprt); LVEncoderListener(lv_indev_type_t type, uint16_t lpt, uint16_t lprt);
@ -218,9 +220,11 @@ class LVEncoderListener : public Parented<LvglComponent> {
enter_button->add_on_state_callback([this](bool state) { this->event(LV_KEY_ENTER, state); }); enter_button->add_on_state_callback([this](bool state) { this->event(LV_KEY_ENTER, state); });
} }
#ifdef USE_LVGL_ROTARY_ENCODER
void set_sensor(rotary_encoder::RotaryEncoderSensor *sensor) { void set_sensor(rotary_encoder::RotaryEncoderSensor *sensor) {
sensor->register_listener([this](int32_t count) { this->set_count(count); }); sensor->register_listener([this](int32_t count) { this->set_count(count); });
} }
#endif // USE_LVGL_ROTARY_ENCODER
void event(int key, bool pressed) { void event(int key, bool pressed) {
if (!this->parent_->is_paused()) { if (!this->parent_->is_paused()) {
@ -243,7 +247,8 @@ class LVEncoderListener : public Parented<LvglComponent> {
int32_t last_count_{}; int32_t last_count_{};
int key_{}; int key_{};
}; };
#endif // USE_LVGL_ROTARY_ENCODER #endif // USE_LVGL_KEY_LISTENER
#ifdef USE_LVGL_BUTTONMATRIX #ifdef USE_LVGL_BUTTONMATRIX
class LvButtonMatrixType : public key_provider::KeyProvider, public LvCompound { class LvButtonMatrixType : public key_provider::KeyProvider, public LvCompound {
public: public:

View file

@ -7,6 +7,7 @@ from esphome.const import (
CONF_ID, CONF_ID,
CONF_ON_VALUE, CONF_ON_VALUE,
CONF_STATE, CONF_STATE,
CONF_TEXT,
CONF_TRIGGER_ID, CONF_TRIGGER_ID,
CONF_TYPE, CONF_TYPE,
) )
@ -15,9 +16,9 @@ from esphome.schema_extractors import SCHEMA_EXTRACT
from . import defines as df, lv_validation as lvalid, types as ty from . import defines as df, lv_validation as lvalid, types as ty
from .helpers import add_lv_use, requires_component, validate_printf from .helpers import add_lv_use, requires_component, validate_printf
from .lv_validation import id_name, lv_color, lv_font, lv_image from .lv_validation import lv_color, lv_font, lv_image
from .lvcode import LvglComponent from .lvcode import LvglComponent
from .types import WidgetType from .types import WidgetType, lv_group_t
# this will be populated later, in __init__.py to avoid circular imports. # this will be populated later, in __init__.py to avoid circular imports.
WIDGET_TYPES: dict = {} WIDGET_TYPES: dict = {}
@ -25,7 +26,7 @@ WIDGET_TYPES: dict = {}
# A schema for text properties # A schema for text properties
TEXT_SCHEMA = cv.Schema( TEXT_SCHEMA = cv.Schema(
{ {
cv.Optional(df.CONF_TEXT): cv.Any( cv.Optional(CONF_TEXT): cv.Any(
cv.All( cv.All(
cv.Schema( cv.Schema(
{ {
@ -60,7 +61,7 @@ ENCODER_SCHEMA = cv.Schema(
cv.GenerateID(): cv.All( cv.GenerateID(): cv.All(
cv.declare_id(ty.LVEncoderListener), requires_component("binary_sensor") cv.declare_id(ty.LVEncoderListener), requires_component("binary_sensor")
), ),
cv.Optional(CONF_GROUP): lvalid.id_name, cv.Optional(CONF_GROUP): cv.declare_id(lv_group_t),
cv.Optional(df.CONF_LONG_PRESS_TIME, default="400ms"): PRESS_TIME, cv.Optional(df.CONF_LONG_PRESS_TIME, default="400ms"): PRESS_TIME,
cv.Optional(df.CONF_LONG_PRESS_REPEAT_TIME, default="100ms"): PRESS_TIME, cv.Optional(df.CONF_LONG_PRESS_REPEAT_TIME, default="100ms"): PRESS_TIME,
} }
@ -248,7 +249,7 @@ def obj_schema(widget_type: WidgetType):
cv.Schema( cv.Schema(
{ {
cv.Optional(CONF_STATE): SET_STATE_SCHEMA, cv.Optional(CONF_STATE): SET_STATE_SCHEMA,
cv.Optional(CONF_GROUP): id_name, cv.Optional(CONF_GROUP): cv.use_id(lv_group_t),
} }
) )
) )
@ -330,7 +331,7 @@ DISP_BG_SCHEMA = cv.Schema(
# A style schema that can include text # A style schema that can include text
STYLED_TEXT_SCHEMA = cv.maybe_simple_value( STYLED_TEXT_SCHEMA = cv.maybe_simple_value(
STYLE_SCHEMA.extend(TEXT_SCHEMA), key=df.CONF_TEXT STYLE_SCHEMA.extend(TEXT_SCHEMA), key=CONF_TEXT
) )
# For use by platform components # For use by platform components

View file

@ -1,10 +1,10 @@
import sys import sys
from esphome import automation, codegen as cg from esphome import automation, codegen as cg
from esphome.const import CONF_MAX_VALUE, CONF_MIN_VALUE, CONF_VALUE from esphome.const import CONF_MAX_VALUE, CONF_MIN_VALUE, CONF_TEXT, CONF_VALUE
from esphome.cpp_generator import MockObj, MockObjClass from esphome.cpp_generator import MockObj, MockObjClass
from .defines import CONF_TEXT, lvgl_ns from .defines import lvgl_ns
from .lvcode import lv_expr from .lvcode import lv_expr

View file

@ -6,7 +6,7 @@ from esphome.config_validation import Invalid
from esphome.const import CONF_GROUP, CONF_ID, CONF_STATE, CONF_TYPE from esphome.const import CONF_GROUP, CONF_ID, CONF_STATE, CONF_TYPE
from esphome.core import ID, TimePeriod from esphome.core import ID, TimePeriod
from esphome.coroutine import FakeAwaitable from esphome.coroutine import FakeAwaitable
from esphome.cpp_generator import AssignmentExpression, CallExpression, MockObj from esphome.cpp_generator import CallExpression, MockObj
from ..defines import ( from ..defines import (
CONF_DEFAULT, CONF_DEFAULT,
@ -44,15 +44,7 @@ from ..lvcode import (
lv_Pvariable, lv_Pvariable,
) )
from ..schemas import ALL_STYLES, STYLE_REMAP, WIDGET_TYPES from ..schemas import ALL_STYLES, STYLE_REMAP, WIDGET_TYPES
from ..types import ( from ..types import LV_STATE, LvType, WidgetType, lv_coord_t, lv_obj_t, lv_obj_t_ptr
LV_STATE,
LvType,
WidgetType,
lv_coord_t,
lv_group_t,
lv_obj_t,
lv_obj_t_ptr,
)
EVENT_LAMB = "event_lamb__" EVENT_LAMB = "event_lamb__"
@ -317,7 +309,8 @@ async def set_obj_properties(w: Widget, config):
value = await ALL_STYLES[prop].process(value) value = await ALL_STYLES[prop].process(value)
prop_r = STYLE_REMAP.get(prop, prop) prop_r = STYLE_REMAP.get(prop, prop)
w.set_style(prop_r, value, lv_state) w.set_style(prop_r, value, lv_state)
if group := add_group(config.get(CONF_GROUP)): if group := config.get(CONF_GROUP):
group = await cg.get_variable(group)
lv.group_add_obj(group, w.obj) lv.group_add_obj(group, w.obj)
flag_clr = set() flag_clr = set()
flag_set = set() flag_set = set()
@ -404,20 +397,3 @@ async def widget_to_code(w_cnfig, w_type: WidgetType, parent):
lv_scr_act_spec = LvScrActType() lv_scr_act_spec = LvScrActType()
lv_scr_act = Widget.create(None, literal("lv_scr_act()"), lv_scr_act_spec, {}) lv_scr_act = Widget.create(None, literal("lv_scr_act()"), lv_scr_act_spec, {})
lv_groups = {} # Widget group names
def add_group(name):
if name is None:
return None
fullname = f"lv_esp_group_{name}"
if name not in lv_groups:
gid = ID(fullname, True, type=lv_group_t.operator("ptr"))
lv_add(
AssignmentExpression(
type_=gid.type, modifier="", name=fullname, rhs=lv_expr.group_create()
)
)
lv_groups[name] = literal(fullname)
return lv_groups[name]

View file

@ -2,7 +2,7 @@ from esphome import automation
import esphome.codegen as cg import esphome.codegen as cg
from esphome.components.key_provider import KeyProvider from esphome.components.key_provider import KeyProvider
import esphome.config_validation as cv import esphome.config_validation as cv
from esphome.const import CONF_ID, CONF_WIDTH from esphome.const import CONF_ID, CONF_ITEMS, CONF_TEXT, CONF_WIDTH
from esphome.cpp_generator import MockObj from esphome.cpp_generator import MockObj
from ..automation import action_to_code from ..automation import action_to_code
@ -10,13 +10,11 @@ from ..defines import (
BUTTONMATRIX_CTRLS, BUTTONMATRIX_CTRLS,
CONF_BUTTONS, CONF_BUTTONS,
CONF_CONTROL, CONF_CONTROL,
CONF_ITEMS,
CONF_KEY_CODE, CONF_KEY_CODE,
CONF_MAIN, CONF_MAIN,
CONF_ONE_CHECKED, CONF_ONE_CHECKED,
CONF_ROWS, CONF_ROWS,
CONF_SELECTED, CONF_SELECTED,
CONF_TEXT,
) )
from ..helpers import lvgl_components_required from ..helpers import lvgl_components_required
from ..lv_validation import key_code, lv_bool from ..lv_validation import key_code, lv_bool

View file

@ -1,4 +1,6 @@
from ..defines import CONF_INDICATOR, CONF_MAIN, CONF_TEXT from esphome.const import CONF_TEXT
from ..defines import CONF_INDICATOR, CONF_MAIN
from ..lv_validation import lv_text from ..lv_validation import lv_text
from ..lvcode import lv from ..lvcode import lv
from ..schemas import TEXT_SCHEMA from ..schemas import TEXT_SCHEMA

View file

@ -1,9 +1,9 @@
from esphome.components.key_provider import KeyProvider from esphome.components.key_provider import KeyProvider
import esphome.config_validation as cv import esphome.config_validation as cv
from esphome.const import CONF_MODE from esphome.const import CONF_ITEMS, CONF_MODE
from esphome.cpp_types import std_string from esphome.cpp_types import std_string
from ..defines import CONF_ITEMS, CONF_MAIN, KEYBOARD_MODES, literal from ..defines import CONF_MAIN, KEYBOARD_MODES, literal
from ..helpers import add_lv_use, lvgl_components_required from ..helpers import add_lv_use, lvgl_components_required
from ..types import LvCompound, LvType from ..types import LvCompound, LvType
from . import Widget, WidgetType, get_widgets from . import Widget, WidgetType, get_widgets

View file

@ -1,4 +1,5 @@
import esphome.config_validation as cv import esphome.config_validation as cv
from esphome.const import CONF_TEXT
from ..defines import ( from ..defines import (
CONF_LONG_MODE, CONF_LONG_MODE,
@ -6,7 +7,6 @@ from ..defines import (
CONF_RECOLOR, CONF_RECOLOR,
CONF_SCROLLBAR, CONF_SCROLLBAR,
CONF_SELECTED, CONF_SELECTED,
CONF_TEXT,
LV_LONG_MODES, LV_LONG_MODES,
) )
from ..lv_validation import lv_bool, lv_text from ..lv_validation import lv_bool, lv_text

View file

@ -1,5 +1,5 @@
from esphome import config_validation as cv from esphome import config_validation as cv
from esphome.const import CONF_BUTTON, CONF_ID from esphome.const import CONF_BUTTON, CONF_ID, CONF_TEXT
from esphome.core import ID from esphome.core import ID
from esphome.cpp_generator import new_Pvariable, static_const_array from esphome.cpp_generator import new_Pvariable, static_const_array
from esphome.cpp_types import nullptr from esphome.cpp_types import nullptr
@ -9,7 +9,6 @@ from ..defines import (
CONF_BUTTONS, CONF_BUTTONS,
CONF_CLOSE_BUTTON, CONF_CLOSE_BUTTON,
CONF_MSGBOXES, CONF_MSGBOXES,
CONF_TEXT,
CONF_TITLE, CONF_TITLE,
TYPE_FLEX, TYPE_FLEX,
literal, literal,

View file

@ -1,5 +1,5 @@
import esphome.config_validation as cv import esphome.config_validation as cv
from esphome.const import CONF_MAX_LENGTH from esphome.const import CONF_MAX_LENGTH, CONF_TEXT
from ..defines import ( from ..defines import (
CONF_ACCEPTED_CHARS, CONF_ACCEPTED_CHARS,
@ -10,7 +10,6 @@ from ..defines import (
CONF_PLACEHOLDER_TEXT, CONF_PLACEHOLDER_TEXT,
CONF_SCROLLBAR, CONF_SCROLLBAR,
CONF_SELECTED, CONF_SELECTED,
CONF_TEXT,
CONF_TEXTAREA_PLACEHOLDER, CONF_TEXTAREA_PLACEHOLDER,
) )
from ..lv_validation import lv_bool, lv_int, lv_text from ..lv_validation import lv_bool, lv_int, lv_text

View file

@ -1,6 +1,6 @@
import esphome.codegen as cg import esphome.codegen as cg
import esphome.config_validation as cv
from esphome.components import sensor, spi from esphome.components import sensor, spi
import esphome.config_validation as cv
from esphome.const import ( from esphome.const import (
CONF_MAINS_FILTER, CONF_MAINS_FILTER,
DEVICE_CLASS_TEMPERATURE, DEVICE_CLASS_TEMPERATURE,
@ -15,8 +15,8 @@ MAX31856Sensor = max31856_ns.class_(
MAX31865ConfigFilter = max31856_ns.enum("MAX31856ConfigFilter") MAX31865ConfigFilter = max31856_ns.enum("MAX31856ConfigFilter")
FILTER = { FILTER = {
"50HZ": MAX31865ConfigFilter.FILTER_50HZ, 50: MAX31865ConfigFilter.FILTER_50HZ,
"60HZ": MAX31865ConfigFilter.FILTER_60HZ, 60: MAX31865ConfigFilter.FILTER_60HZ,
} }
CONFIG_SCHEMA = ( CONFIG_SCHEMA = (
@ -29,8 +29,8 @@ CONFIG_SCHEMA = (
) )
.extend( .extend(
{ {
cv.Optional(CONF_MAINS_FILTER, default="60HZ"): cv.enum( cv.Optional(CONF_MAINS_FILTER, default="60Hz"): cv.All(
FILTER, upper=True, space="" cv.frequency, cv.enum(FILTER, int=True)
), ),
} }
) )

View file

@ -1,20 +1,18 @@
from esphome import automation from esphome import automation
import esphome.config_validation as cv
import esphome.codegen as cg
from esphome.automation import maybe_simple_id from esphome.automation import maybe_simple_id
import esphome.codegen as cg
import esphome.config_validation as cv
from esphome.const import ( from esphome.const import (
CONF_ID, CONF_ID,
CONF_ON_IDLE,
CONF_ON_STATE, CONF_ON_STATE,
CONF_TRIGGER_ID, CONF_TRIGGER_ID,
CONF_VOLUME, CONF_VOLUME,
CONF_ON_IDLE,
) )
from esphome.core import CORE from esphome.core import CORE
from esphome.coroutine import coroutine_with_priority from esphome.coroutine import coroutine_with_priority
from esphome.cpp_helpers import setup_entity from esphome.cpp_helpers import setup_entity
CODEOWNERS = ["@jesserockz"] CODEOWNERS = ["@jesserockz"]
IS_PLATFORM_COMPONENT = True IS_PLATFORM_COMPONENT = True

View file

@ -1,24 +1,23 @@
import esphome.codegen as cg
import esphome.config_validation as cv
from esphome import automation from esphome import automation
from esphome.components import mqtt import esphome.codegen as cg
from esphome.components import web_server from esphome.components import mqtt, web_server
import esphome.config_validation as cv
from esphome.const import ( from esphome.const import (
CONF_ABOVE, CONF_ABOVE,
CONF_BELOW, CONF_BELOW,
CONF_CYCLE,
CONF_DEVICE_CLASS, CONF_DEVICE_CLASS,
CONF_ENTITY_CATEGORY, CONF_ENTITY_CATEGORY,
CONF_ID,
CONF_ICON, CONF_ICON,
CONF_ID,
CONF_MODE, CONF_MODE,
CONF_MQTT_ID,
CONF_ON_VALUE, CONF_ON_VALUE,
CONF_ON_VALUE_RANGE, CONF_ON_VALUE_RANGE,
CONF_OPERATION,
CONF_TRIGGER_ID, CONF_TRIGGER_ID,
CONF_UNIT_OF_MEASUREMENT, CONF_UNIT_OF_MEASUREMENT,
CONF_MQTT_ID,
CONF_VALUE, CONF_VALUE,
CONF_OPERATION,
CONF_CYCLE,
CONF_WEB_SERVER_ID, CONF_WEB_SERVER_ID,
DEVICE_CLASS_APPARENT_POWER, DEVICE_CLASS_APPARENT_POWER,
DEVICE_CLASS_AQI, DEVICE_CLASS_AQI,
@ -72,8 +71,8 @@ from esphome.const import (
DEVICE_CLASS_WIND_SPEED, DEVICE_CLASS_WIND_SPEED,
) )
from esphome.core import CORE, coroutine_with_priority from esphome.core import CORE, coroutine_with_priority
from esphome.cpp_helpers import setup_entity
from esphome.cpp_generator import MockObjClass from esphome.cpp_generator import MockObjClass
from esphome.cpp_helpers import setup_entity
CODEOWNERS = ["@esphome/core"] CODEOWNERS = ["@esphome/core"]
DEVICE_CLASSES = [ DEVICE_CLASSES = [

View file

@ -49,7 +49,7 @@ class RemoteTransmitterComponent : public remote_base::RemoteTransmitterBase,
#ifdef USE_ESP32 #ifdef USE_ESP32
void configure_rmt_(); void configure_rmt_();
uint32_t current_carrier_frequency_{UINT32_MAX}; uint32_t current_carrier_frequency_{38000};
bool initialized_{false}; bool initialized_{false};
std::vector<rmt_item32_t> rmt_temp_; std::vector<rmt_item32_t> rmt_temp_;
esp_err_t error_code_{ESP_OK}; esp_err_t error_code_{ESP_OK};

View file

@ -1,20 +1,20 @@
import esphome.codegen as cg
import esphome.config_validation as cv
from esphome import automation from esphome import automation
import esphome.codegen as cg
from esphome.components import mqtt, web_server from esphome.components import mqtt, web_server
import esphome.config_validation as cv
from esphome.const import ( from esphome.const import (
CONF_CYCLE,
CONF_ENTITY_CATEGORY, CONF_ENTITY_CATEGORY,
CONF_ICON, CONF_ICON,
CONF_ID, CONF_ID,
CONF_INDEX,
CONF_MODE,
CONF_MQTT_ID,
CONF_ON_VALUE, CONF_ON_VALUE,
CONF_OPERATION,
CONF_OPTION, CONF_OPTION,
CONF_TRIGGER_ID, CONF_TRIGGER_ID,
CONF_MQTT_ID,
CONF_WEB_SERVER_ID, CONF_WEB_SERVER_ID,
CONF_CYCLE,
CONF_MODE,
CONF_OPERATION,
CONF_INDEX,
) )
from esphome.core import CORE, coroutine_with_priority from esphome.core import CORE, coroutine_with_priority
from esphome.cpp_generator import MockObjClass from esphome.cpp_generator import MockObjClass

View file

@ -1,22 +1,27 @@
import math import math
import esphome.codegen as cg
import esphome.config_validation as cv
from esphome import automation from esphome import automation
import esphome.codegen as cg
from esphome.components import mqtt, web_server from esphome.components import mqtt, web_server
import esphome.config_validation as cv
from esphome.const import ( from esphome.const import (
CONF_DEVICE_CLASS,
CONF_ABOVE, CONF_ABOVE,
CONF_ACCURACY_DECIMALS, CONF_ACCURACY_DECIMALS,
CONF_ALPHA, CONF_ALPHA,
CONF_BELOW, CONF_BELOW,
CONF_DEVICE_CLASS,
CONF_ENTITY_CATEGORY, CONF_ENTITY_CATEGORY,
CONF_EXPIRE_AFTER, CONF_EXPIRE_AFTER,
CONF_FILTERS, CONF_FILTERS,
CONF_FORCE_UPDATE,
CONF_FROM, CONF_FROM,
CONF_ICON, CONF_ICON,
CONF_ID, CONF_ID,
CONF_IGNORE_OUT_OF_RANGE, CONF_IGNORE_OUT_OF_RANGE,
CONF_MAX_VALUE,
CONF_METHOD,
CONF_MIN_VALUE,
CONF_MQTT_ID,
CONF_MULTIPLE, CONF_MULTIPLE,
CONF_ON_RAW_VALUE, CONF_ON_RAW_VALUE,
CONF_ON_VALUE, CONF_ON_VALUE,
@ -30,14 +35,9 @@ from esphome.const import (
CONF_TRIGGER_ID, CONF_TRIGGER_ID,
CONF_TYPE, CONF_TYPE,
CONF_UNIT_OF_MEASUREMENT, CONF_UNIT_OF_MEASUREMENT,
CONF_WINDOW_SIZE,
CONF_MQTT_ID,
CONF_WEB_SERVER_ID,
CONF_FORCE_UPDATE,
CONF_VALUE, CONF_VALUE,
CONF_MIN_VALUE, CONF_WEB_SERVER_ID,
CONF_MAX_VALUE, CONF_WINDOW_SIZE,
CONF_METHOD,
DEVICE_CLASS_APPARENT_POWER, DEVICE_CLASS_APPARENT_POWER,
DEVICE_CLASS_AQI, DEVICE_CLASS_AQI,
DEVICE_CLASS_ATMOSPHERIC_PRESSURE, DEVICE_CLASS_ATMOSPHERIC_PRESSURE,

View file

@ -7,10 +7,6 @@ namespace spi {
const char *const TAG = "spi"; const char *const TAG = "spi";
SPIDelegate *const SPIDelegate::NULL_DELEGATE = // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
new SPIDelegateDummy();
// https://bugs.llvm.org/show_bug.cgi?id=48040
bool SPIDelegate::is_ready() { return true; } bool SPIDelegate::is_ready() { return true; }
GPIOPin *const NullPin::NULL_PIN = new NullPin(); // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) GPIOPin *const NullPin::NULL_PIN = new NullPin(); // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
@ -79,8 +75,6 @@ void SPIComponent::dump_config() {
} }
} }
void SPIDelegateDummy::begin_transaction() { ESP_LOGE(TAG, "SPIDevice not initialised - did you call spi_setup()?"); }
uint8_t SPIDelegateBitBash::transfer(uint8_t data) { return this->transfer_(data, 8); } uint8_t SPIDelegateBitBash::transfer(uint8_t data) { return this->transfer_(data, 8); }
void SPIDelegateBitBash::write(uint16_t data, size_t num_bits) { this->transfer_(data, num_bits); } void SPIDelegateBitBash::write(uint16_t data, size_t num_bits) { this->transfer_(data, num_bits); }

View file

@ -163,8 +163,6 @@ class Utility {
} }
}; };
class SPIDelegateDummy;
// represents a device attached to an SPI bus, with a defined clock rate, mode and bit order. On Arduino this is // represents a device attached to an SPI bus, with a defined clock rate, mode and bit order. On Arduino this is
// a thin wrapper over SPIClass. // a thin wrapper over SPIClass.
class SPIDelegate { class SPIDelegate {
@ -250,21 +248,6 @@ class SPIDelegate {
uint32_t data_rate_{1000000}; uint32_t data_rate_{1000000};
SPIMode mode_{MODE0}; SPIMode mode_{MODE0};
GPIOPin *cs_pin_{NullPin::NULL_PIN}; GPIOPin *cs_pin_{NullPin::NULL_PIN};
static SPIDelegate *const NULL_DELEGATE; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
};
/**
* A dummy SPIDelegate that complains if it's used.
*/
class SPIDelegateDummy : public SPIDelegate {
public:
SPIDelegateDummy() = default;
uint8_t transfer(uint8_t data) override { return 0; }
void end_transaction() override{};
void begin_transaction() override;
}; };
/** /**
@ -382,7 +365,7 @@ class SPIClient {
virtual void spi_teardown() { virtual void spi_teardown() {
this->parent_->unregister_device(this); this->parent_->unregister_device(this);
this->delegate_ = SPIDelegate::NULL_DELEGATE; this->delegate_ = nullptr;
} }
bool spi_is_ready() { return this->delegate_->is_ready(); } bool spi_is_ready() { return this->delegate_->is_ready(); }
@ -393,7 +376,7 @@ class SPIClient {
uint32_t data_rate_{1000000}; uint32_t data_rate_{1000000};
SPIComponent *parent_{nullptr}; SPIComponent *parent_{nullptr};
GPIOPin *cs_{nullptr}; GPIOPin *cs_{nullptr};
SPIDelegate *delegate_{SPIDelegate::NULL_DELEGATE}; SPIDelegate *delegate_{nullptr};
}; };
/** /**

View file

@ -1,8 +1,8 @@
import esphome.codegen as cg
import esphome.config_validation as cv
from esphome import automation from esphome import automation
from esphome.automation import Condition, maybe_simple_id from esphome.automation import Condition, maybe_simple_id
import esphome.codegen as cg
from esphome.components import mqtt, web_server from esphome.components import mqtt, web_server
import esphome.config_validation as cv
from esphome.const import ( from esphome.const import (
CONF_DEVICE_CLASS, CONF_DEVICE_CLASS,
CONF_ENTITY_CATEGORY, CONF_ENTITY_CATEGORY,
@ -10,11 +10,11 @@ from esphome.const import (
CONF_ID, CONF_ID,
CONF_INVERTED, CONF_INVERTED,
CONF_MQTT_ID, CONF_MQTT_ID,
CONF_WEB_SERVER_ID,
CONF_ON_TURN_OFF, CONF_ON_TURN_OFF,
CONF_ON_TURN_ON, CONF_ON_TURN_ON,
CONF_RESTORE_MODE, CONF_RESTORE_MODE,
CONF_TRIGGER_ID, CONF_TRIGGER_ID,
CONF_WEB_SERVER_ID,
DEVICE_CLASS_EMPTY, DEVICE_CLASS_EMPTY,
DEVICE_CLASS_OUTLET, DEVICE_CLASS_OUTLET,
DEVICE_CLASS_SWITCH, DEVICE_CLASS_SWITCH,

View file

@ -1,18 +1,18 @@
from typing import Optional from typing import Optional
import esphome.codegen as cg
import esphome.config_validation as cv
from esphome import automation from esphome import automation
import esphome.codegen as cg
from esphome.components import mqtt, web_server from esphome.components import mqtt, web_server
import esphome.config_validation as cv
from esphome.const import ( from esphome.const import (
CONF_ID, CONF_ID,
CONF_MODE, CONF_MODE,
CONF_MQTT_ID,
CONF_ON_VALUE, CONF_ON_VALUE,
CONF_TRIGGER_ID, CONF_TRIGGER_ID,
CONF_MQTT_ID,
CONF_WEB_SERVER_ID,
CONF_VALUE, CONF_VALUE,
CONF_WEB_SERVER_ID,
) )
from esphome.core import CORE, coroutine_with_priority from esphome.core import CORE, coroutine_with_priority
from esphome.cpp_helpers import setup_entity from esphome.cpp_helpers import setup_entity

View file

@ -1,21 +1,21 @@
import esphome.codegen as cg
import esphome.config_validation as cv
from esphome import automation from esphome import automation
import esphome.codegen as cg
from esphome.components import mqtt, web_server from esphome.components import mqtt, web_server
import esphome.config_validation as cv
from esphome.const import ( from esphome.const import (
CONF_DEVICE_CLASS, CONF_DEVICE_CLASS,
CONF_ENTITY_CATEGORY, CONF_ENTITY_CATEGORY,
CONF_FILTERS, CONF_FILTERS,
CONF_FROM,
CONF_ICON, CONF_ICON,
CONF_ID, CONF_ID,
CONF_ON_VALUE,
CONF_ON_RAW_VALUE,
CONF_TRIGGER_ID,
CONF_MQTT_ID, CONF_MQTT_ID,
CONF_WEB_SERVER_ID, CONF_ON_RAW_VALUE,
CONF_ON_VALUE,
CONF_STATE, CONF_STATE,
CONF_FROM,
CONF_TO, CONF_TO,
CONF_TRIGGER_ID,
CONF_WEB_SERVER_ID,
DEVICE_CLASS_DATE, DEVICE_CLASS_DATE,
DEVICE_CLASS_EMPTY, DEVICE_CLASS_EMPTY,
DEVICE_CLASS_TIMESTAMP, DEVICE_CLASS_TIMESTAMP,

View file

@ -1,8 +1,8 @@
import esphome.codegen as cg
import esphome.config_validation as cv
from esphome import automation from esphome import automation
from esphome.automation import maybe_simple_id, Condition from esphome.automation import Condition, maybe_simple_id
import esphome.codegen as cg
from esphome.components import mqtt, web_server from esphome.components import mqtt, web_server
import esphome.config_validation as cv
from esphome.const import ( from esphome.const import (
CONF_DEVICE_CLASS, CONF_DEVICE_CLASS,
CONF_ID, CONF_ID,

View file

@ -310,6 +310,7 @@ CONF_FLASH_LENGTH = "flash_length"
CONF_FLASH_TRANSITION_LENGTH = "flash_transition_length" CONF_FLASH_TRANSITION_LENGTH = "flash_transition_length"
CONF_FLOW = "flow" CONF_FLOW = "flow"
CONF_FLOW_CONTROL_PIN = "flow_control_pin" CONF_FLOW_CONTROL_PIN = "flow_control_pin"
CONF_FONT = "font"
CONF_FOR = "for" CONF_FOR = "for"
CONF_FORCE_UPDATE = "force_update" CONF_FORCE_UPDATE = "force_update"
CONF_FOREGROUND_COLOR = "foreground_color" CONF_FOREGROUND_COLOR = "foreground_color"
@ -409,6 +410,7 @@ CONF_INVERTED = "inverted"
CONF_IP_ADDRESS = "ip_address" CONF_IP_ADDRESS = "ip_address"
CONF_IRQ_PIN = "irq_pin" CONF_IRQ_PIN = "irq_pin"
CONF_IS_RGBW = "is_rgbw" CONF_IS_RGBW = "is_rgbw"
CONF_ITEMS = "items"
CONF_JS_INCLUDE = "js_include" CONF_JS_INCLUDE = "js_include"
CONF_JS_URL = "js_url" CONF_JS_URL = "js_url"
CONF_JVC = "jvc" CONF_JVC = "jvc"
@ -843,6 +845,7 @@ CONF_TEMPERATURE = "temperature"
CONF_TEMPERATURE_OFFSET = "temperature_offset" CONF_TEMPERATURE_OFFSET = "temperature_offset"
CONF_TEMPERATURE_SOURCE = "temperature_source" CONF_TEMPERATURE_SOURCE = "temperature_source"
CONF_TEMPERATURE_STEP = "temperature_step" CONF_TEMPERATURE_STEP = "temperature_step"
CONF_TEXT = "text"
CONF_TEXT_SENSORS = "text_sensors" CONF_TEXT_SENSORS = "text_sensors"
CONF_THEN = "then" CONF_THEN = "then"
CONF_THRESHOLD = "threshold" CONF_THRESHOLD = "threshold"

View file

@ -62,24 +62,6 @@ class GPIOPin {
virtual bool is_internal() { return false; } virtual bool is_internal() { return false; }
}; };
/**
* A pin to replace those that don't exist.
*/
class NullPin : public GPIOPin {
public:
void setup() override {}
void pin_mode(gpio::Flags _) override {}
bool digital_read() override { return false; }
void digital_write(bool _) override {}
std::string dump_summary() const override { return {"Not used"}; }
};
static GPIOPin *const NULL_PIN = new NullPin(); // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
/// Copy of GPIOPin that is safe to use from ISRs (with no virtual functions) /// Copy of GPIOPin that is safe to use from ISRs (with no virtual functions)
class ISRInternalGPIOPin { class ISRInternalGPIOPin {
public: public:

View file

@ -3,7 +3,6 @@ import hashlib
import json import json
import logging import logging
import ssl import ssl
import sys
import time import time
import paho.mqtt.client as mqtt import paho.mqtt.client as mqtt
@ -103,10 +102,7 @@ def prepare(
if config[CONF_MQTT].get(CONF_SSL_FINGERPRINTS) or config[CONF_MQTT].get( if config[CONF_MQTT].get(CONF_SSL_FINGERPRINTS) or config[CONF_MQTT].get(
CONF_CERTIFICATE_AUTHORITY CONF_CERTIFICATE_AUTHORITY
): ):
if sys.version_info >= (2, 7, 13): tls_version = ssl.PROTOCOL_TLS # pylint: disable=no-member
tls_version = ssl.PROTOCOL_TLS # pylint: disable=no-member
else:
tls_version = ssl.PROTOCOL_SSLv23
client.tls_set( client.tls_set(
ca_certs=None, ca_certs=None,
certfile=None, certfile=None,

View file

@ -1,13 +1,13 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
from pathlib import Path
import sys
import argparse import argparse
from collections import defaultdict from collections import defaultdict
from pathlib import Path
import sys
from esphome.helpers import write_file_if_changed
from esphome.config import get_component, get_platform from esphome.config import get_component, get_platform
from esphome.core import CORE
from esphome.const import KEY_CORE, KEY_TARGET_FRAMEWORK from esphome.const import KEY_CORE, KEY_TARGET_FRAMEWORK
from esphome.core import CORE
from esphome.helpers import write_file_if_changed
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
parser.add_argument( parser.add_argument(

View file

@ -1,9 +1,10 @@
import argparse
import glob
import inspect import inspect
import json import json
import argparse
import os import os
import glob
import re import re
import voluptuous as vol import voluptuous as vol
# NOTE: Cannot import other esphome components globally as a modification in vol_schema # NOTE: Cannot import other esphome components globally as a modification in vol_schema
@ -94,13 +95,12 @@ load_components()
# Import esphome after loading components (so schema is tracked) # Import esphome after loading components (so schema is tracked)
# pylint: disable=wrong-import-position # pylint: disable=wrong-import-position
import esphome.core as esphome_core from esphome import automation, pins
import esphome.config_validation as cv
from esphome import automation
from esphome import pins
from esphome.components import remote_base from esphome.components import remote_base
from esphome.loader import get_platform, CORE_COMPONENTS_PATH import esphome.config_validation as cv
import esphome.core as esphome_core
from esphome.helpers import write_file_if_changed from esphome.helpers import write_file_if_changed
from esphome.loader import CORE_COMPONENTS_PATH, get_platform
from esphome.util import Registry from esphome.util import Registry
# pylint: enable=wrong-import-position # pylint: enable=wrong-import-position

View file

@ -1,8 +1,8 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import argparse import argparse
import re
from dataclasses import dataclass from dataclasses import dataclass
import re
import sys import sys

View file

@ -1,15 +1,6 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
from helpers import (
print_error_for_file,
get_output,
git_ls_files,
filter_changed,
get_binary,
)
import argparse import argparse
import click
import colorama
import multiprocessing import multiprocessing
import os import os
import queue import queue
@ -18,6 +9,9 @@ import subprocess
import sys import sys
import threading import threading
import click
import colorama
from helpers import filter_changed, get_binary, git_ls_files, print_error_for_file
def run_format(executable, args, queue, lock, failed_files): def run_format(executable, args, queue, lock, failed_files):

View file

@ -1,19 +1,20 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
from helpers import (
styled,
print_error_for_file,
get_output,
get_err,
git_ls_files,
filter_changed,
)
import argparse import argparse
import colorama
import os import os
import re import re
import sys import sys
import colorama
from helpers import (
filter_changed,
get_err,
get_output,
git_ls_files,
print_error_for_file,
styled,
)
curfile = None curfile = None

View file

@ -1,11 +1,10 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import argparse
from pathlib import Path from pathlib import Path
import sys import sys
import argparse
from helpers import git_ls_files, changed_files from helpers import changed_files, git_ls_files
from esphome.loader import get_component, get_platform
from esphome.core import CORE
from esphome.const import ( from esphome.const import (
KEY_CORE, KEY_CORE,
KEY_TARGET_FRAMEWORK, KEY_TARGET_FRAMEWORK,
@ -13,6 +12,8 @@ from esphome.const import (
PLATFORM_ESP32, PLATFORM_ESP32,
PLATFORM_ESP8266, PLATFORM_ESP8266,
) )
from esphome.core import CORE
from esphome.loader import get_component, get_platform
def filter_component_files(str): def filter_component_files(str):

View file

@ -24,6 +24,33 @@ display:
invert_colors: false invert_colors: false
update_interval: never update_interval: never
binary_sensor:
- platform: gpio
internal: true
id: up_button
pin:
number: GPIO38
inverted: true
- platform: gpio
internal: true
id: down_button
pin:
number: GPIO37
inverted: true
- platform: gpio
internal: true
id: select_button
pin:
number: GPIO39
inverted: true
lvgl:
encoders:
group: switches
enter_button: select_button
sensor:
left_button: up_button
right_button: down_button
packages: packages:
lvgl: !include lvgl-package.yaml lvgl: !include lvgl-package.yaml

View file

@ -67,7 +67,7 @@ lvgl:
displays: displays:
- tft_display - tft_display
- second_display - second_display
rotary_encoders: encoders:
sensor: encoder sensor: encoder
enter_button: pushbutton enter_button: pushbutton
group: general group: general