1
0
mirror of https://github.com/esphome/esphome.git synced 2024-10-07 03:11:00 +01:00

Merge pull request #3177 from esphome/bump-2022.1.4

2022.1.4
This commit is contained in:
Jesse Hills 2022-02-09 12:42:47 +13:00 committed by GitHub
commit 09ed1aed93
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 19 deletions

View File

@ -14,10 +14,14 @@ CONF_BIT_RATE = "bit_rate"
CONF_ON_FRAME = "on_frame" CONF_ON_FRAME = "on_frame"
def validate_id(id_value, id_ext): def validate_id(config):
if not id_ext: if CONF_CAN_ID in config:
if id_value > 0x7FF: id_value = config[CONF_CAN_ID]
raise cv.Invalid("Standard IDs must be 11 Bit (0x000-0x7ff / 0-2047)") id_ext = config[CONF_USE_EXTENDED_ID]
if not id_ext:
if id_value > 0x7FF:
raise cv.Invalid("Standard IDs must be 11 Bit (0x000-0x7ff / 0-2047)")
return config
def validate_raw_data(value): def validate_raw_data(value):
@ -67,23 +71,18 @@ CANBUS_SCHEMA = cv.Schema(
cv.Optional(CONF_ON_FRAME): automation.validate_automation( cv.Optional(CONF_ON_FRAME): automation.validate_automation(
{ {
cv.GenerateID(CONF_TRIGGER_ID): cv.declare_id(CanbusTrigger), cv.GenerateID(CONF_TRIGGER_ID): cv.declare_id(CanbusTrigger),
cv.GenerateID(CONF_CAN_ID): cv.int_range(min=0, max=0x1FFFFFFF), cv.Required(CONF_CAN_ID): cv.int_range(min=0, max=0x1FFFFFFF),
cv.Optional(CONF_USE_EXTENDED_ID, default=False): cv.boolean, cv.Optional(CONF_USE_EXTENDED_ID, default=False): cv.boolean,
cv.Optional(CONF_ON_FRAME): automation.validate_automation( },
{ validate_id,
cv.GenerateID(CONF_TRIGGER_ID): cv.declare_id(CanbusTrigger),
cv.GenerateID(CONF_CAN_ID): cv.int_range(min=0, max=0x1FFFFFFF),
cv.Optional(CONF_USE_EXTENDED_ID, default=False): cv.boolean,
}
),
}
), ),
} },
).extend(cv.COMPONENT_SCHEMA) ).extend(cv.COMPONENT_SCHEMA)
CANBUS_SCHEMA.add_extra(validate_id)
async def setup_canbus_core_(var, config): async def setup_canbus_core_(var, config):
validate_id(config[CONF_CAN_ID], config[CONF_USE_EXTENDED_ID])
await cg.register_component(var, config) await cg.register_component(var, config)
cg.add(var.set_can_id([config[CONF_CAN_ID]])) cg.add(var.set_can_id([config[CONF_CAN_ID]]))
cg.add(var.set_use_extended_id([config[CONF_USE_EXTENDED_ID]])) cg.add(var.set_use_extended_id([config[CONF_USE_EXTENDED_ID]]))
@ -92,7 +91,6 @@ async def setup_canbus_core_(var, config):
for conf in config.get(CONF_ON_FRAME, []): for conf in config.get(CONF_ON_FRAME, []):
can_id = conf[CONF_CAN_ID] can_id = conf[CONF_CAN_ID]
ext_id = conf[CONF_USE_EXTENDED_ID] ext_id = conf[CONF_USE_EXTENDED_ID]
validate_id(can_id, ext_id)
trigger = cg.new_Pvariable(conf[CONF_TRIGGER_ID], var, can_id, ext_id) trigger = cg.new_Pvariable(conf[CONF_TRIGGER_ID], var, can_id, ext_id)
await cg.register_component(trigger, conf) await cg.register_component(trigger, conf)
await automation.build_automation( await automation.build_automation(
@ -117,11 +115,11 @@ async def register_canbus(var, config):
cv.Optional(CONF_USE_EXTENDED_ID, default=False): cv.boolean, cv.Optional(CONF_USE_EXTENDED_ID, default=False): cv.boolean,
cv.Required(CONF_DATA): cv.templatable(validate_raw_data), cv.Required(CONF_DATA): cv.templatable(validate_raw_data),
}, },
validate_id,
key=CONF_DATA, key=CONF_DATA,
), ),
) )
async def canbus_action_to_code(config, action_id, template_arg, args): async def canbus_action_to_code(config, action_id, template_arg, args):
validate_id(config[CONF_CAN_ID], config[CONF_USE_EXTENDED_ID])
var = cg.new_Pvariable(action_id, template_arg) var = cg.new_Pvariable(action_id, template_arg)
await cg.register_parented(var, config[CONF_CANBUS_ID]) await cg.register_parented(var, config[CONF_CANBUS_ID])

View File

@ -1,7 +1,7 @@
from esphome.const import CONF_ID from esphome.const import CONF_ID
import esphome.codegen as cg import esphome.codegen as cg
import esphome.config_validation as cv import esphome.config_validation as cv
from esphome.core import CORE from esphome.core import CORE, coroutine_with_priority
CODEOWNERS = ["@esphome/core"] CODEOWNERS = ["@esphome/core"]
DEPENDENCIES = ["network"] DEPENDENCIES = ["network"]
@ -29,6 +29,7 @@ CONFIG_SCHEMA = cv.All(
) )
@coroutine_with_priority(55.0)
async def to_code(config): async def to_code(config):
if CORE.using_arduino: if CORE.using_arduino:
if CORE.is_esp32: if CORE.is_esp32:

View File

@ -1,6 +1,6 @@
"""Constants used by esphome.""" """Constants used by esphome."""
__version__ = "2022.1.3" __version__ = "2022.1.4"
ALLOWED_NAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789-_" ALLOWED_NAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789-_"