From 55a43a6755c2f90f2738aabb2361259087674b6e Mon Sep 17 00:00:00 2001 From: Anton Viktorov Date: Tue, 3 Sep 2024 12:48:54 +0200 Subject: [PATCH] move constant to consts.py --- esphome/components/lvgl/defines.py | 2 -- esphome/components/lvgl/widgets/img.py | 4 +--- esphome/components/msa3xx/__init__.py | 12 ++++++------ esphome/components/ssd1306_base/__init__.py | 16 ++++++++-------- esphome/const.py | 3 +++ 5 files changed, 18 insertions(+), 19 deletions(-) diff --git a/esphome/components/lvgl/defines.py b/esphome/components/lvgl/defines.py index e05bf52120..c13bbabfcb 100644 --- a/esphome/components/lvgl/defines.py +++ b/esphome/components/lvgl/defines.py @@ -429,8 +429,6 @@ CONF_LVGL_ID = "lvgl_id" CONF_LONG_MODE = "long_mode" CONF_MSGBOXES = "msgboxes" CONF_OBJ = "obj" -CONF_OFFSET_X = "offset_x" -CONF_OFFSET_Y = "offset_y" CONF_ONE_CHECKED = "one_checked" CONF_ONE_LINE = "one_line" CONF_ON_SELECT = "on_select" diff --git a/esphome/components/lvgl/widgets/img.py b/esphome/components/lvgl/widgets/img.py index 59b2c97c63..0e278736d6 100644 --- a/esphome/components/lvgl/widgets/img.py +++ b/esphome/components/lvgl/widgets/img.py @@ -1,11 +1,9 @@ import esphome.config_validation as cv -from esphome.const import CONF_ANGLE, CONF_MODE +from esphome.const import CONF_ANGLE, CONF_MODE, CONF_OFFSET_X, CONF_OFFSET_Y from ..defines import ( CONF_ANTIALIAS, CONF_MAIN, - CONF_OFFSET_X, - CONF_OFFSET_Y, CONF_PIVOT_X, CONF_PIVOT_Y, CONF_SRC, diff --git a/esphome/components/msa3xx/__init__.py b/esphome/components/msa3xx/__init__.py index f32c5cc0e0..1c161a6535 100644 --- a/esphome/components/msa3xx/__init__.py +++ b/esphome/components/msa3xx/__init__.py @@ -1,7 +1,7 @@ -import esphome.codegen as cg -import esphome.config_validation as cv -from esphome.components import i2c from esphome import automation +import esphome.codegen as cg +from esphome.components import i2c +import esphome.config_validation as cv from esphome.const import ( CONF_ADDRESS, CONF_CALIBRATION, @@ -9,6 +9,9 @@ from esphome.const import ( CONF_MIRROR_X, CONF_MIRROR_Y, CONF_MODEL, + CONF_OFFSET_X, + CONF_OFFSET_Y, + CONF_OFFSET_Z, CONF_RANGE, CONF_RESOLUTION, CONF_SWAP_XY, @@ -22,9 +25,6 @@ DEPENDENCIES = ["i2c"] CONF_MSA3XX_ID = "msa3xx_id" CONF_MIRROR_Z = "mirror_z" -CONF_OFFSET_X = "offset_x" -CONF_OFFSET_Y = "offset_y" -CONF_OFFSET_Z = "offset_z" CONF_ON_ACTIVE = "on_active" CONF_ON_DOUBLE_TAP = "on_double_tap" CONF_ON_FREEFALL = "on_freefall" diff --git a/esphome/components/ssd1306_base/__init__.py b/esphome/components/ssd1306_base/__init__.py index 1fe74dfcb5..ab2c7a5496 100644 --- a/esphome/components/ssd1306_base/__init__.py +++ b/esphome/components/ssd1306_base/__init__.py @@ -1,15 +1,17 @@ -import esphome.codegen as cg -import esphome.config_validation as cv from esphome import pins +import esphome.codegen as cg from esphome.components import display +import esphome.config_validation as cv from esphome.const import ( - CONF_EXTERNAL_VCC, - CONF_LAMBDA, - CONF_MODEL, - CONF_RESET_PIN, CONF_BRIGHTNESS, CONF_CONTRAST, + CONF_EXTERNAL_VCC, CONF_INVERT, + CONF_LAMBDA, + CONF_MODEL, + CONF_OFFSET_X, + CONF_OFFSET_Y, + CONF_RESET_PIN, ) ssd1306_base_ns = cg.esphome_ns.namespace("ssd1306_base") @@ -18,8 +20,6 @@ SSD1306Model = ssd1306_base_ns.enum("SSD1306Model") CONF_FLIP_X = "flip_x" CONF_FLIP_Y = "flip_y" -CONF_OFFSET_X = "offset_x" -CONF_OFFSET_Y = "offset_y" MODELS = { "SSD1306_128X32": SSD1306Model.SSD1306_MODEL_128_32, diff --git a/esphome/const.py b/esphome/const.py index 95773630d0..e0cd6adc7f 100644 --- a/esphome/const.py +++ b/esphome/const.py @@ -533,6 +533,9 @@ CONF_OFF_SPEED_CYCLE = "off_speed_cycle" CONF_OFFSET = "offset" CONF_OFFSET_HEIGHT = "offset_height" CONF_OFFSET_WIDTH = "offset_width" +CONF_OFFSET_X = "offset_x" +CONF_OFFSET_Y = "offset_y" +CONF_OFFSET_Z = "offset_z" CONF_ON = "on" CONF_ON_BLE_ADVERTISE = "on_ble_advertise" CONF_ON_BLE_MANUFACTURER_DATA_ADVERTISE = "on_ble_manufacturer_data_advertise"