mirror of
https://github.com/esphome/esphome.git
synced 2026-09-28 15:30:21 +00:00
[core] Migrate trivial action and condition builders to the shared helpers (#19322)
This commit is contained in:
@@ -208,65 +208,50 @@ for _name, _arm in (
|
||||
)
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
automation.register_simple_action(
|
||||
"alarm_control_panel.pending",
|
||||
PendingAction,
|
||||
ALARM_CONTROL_PANEL_ACTION_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
async def alarm_action_pending_to_code(config, action_id, template_arg, args):
|
||||
paren = await cg.get_variable(config[CONF_ID])
|
||||
return cg.new_Pvariable(action_id, template_arg, paren)
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
automation.register_simple_action(
|
||||
"alarm_control_panel.triggered",
|
||||
TriggeredAction,
|
||||
ALARM_CONTROL_PANEL_ACTION_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
async def alarm_action_trigger_to_code(config, action_id, template_arg, args):
|
||||
paren = await cg.get_variable(config[CONF_ID])
|
||||
return cg.new_Pvariable(action_id, template_arg, paren)
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
automation.register_simple_action(
|
||||
"alarm_control_panel.chime",
|
||||
ChimeAction,
|
||||
ALARM_CONTROL_PANEL_ACTION_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
async def alarm_action_chime_to_code(config, action_id, template_arg, args):
|
||||
paren = await cg.get_variable(config[CONF_ID])
|
||||
return cg.new_Pvariable(action_id, template_arg, paren)
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
automation.register_simple_action(
|
||||
"alarm_control_panel.ready",
|
||||
ReadyAction,
|
||||
ALARM_CONTROL_PANEL_ACTION_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
@automation.register_condition(
|
||||
|
||||
|
||||
automation.register_simple_condition(
|
||||
"alarm_control_panel.ready",
|
||||
AlarmControlPanelCondition,
|
||||
ALARM_CONTROL_PANEL_CONDITION_SCHEMA,
|
||||
)
|
||||
async def alarm_action_ready_to_code(config, action_id, template_arg, args):
|
||||
paren = await cg.get_variable(config[CONF_ID])
|
||||
return cg.new_Pvariable(action_id, template_arg, paren)
|
||||
|
||||
|
||||
@automation.register_condition(
|
||||
automation.register_simple_condition(
|
||||
"alarm_control_panel.is_armed",
|
||||
AlarmControlPanelCondition,
|
||||
ALARM_CONTROL_PANEL_CONDITION_SCHEMA,
|
||||
)
|
||||
async def alarm_control_panel_is_armed_to_code(
|
||||
config, condition_id, template_arg, args
|
||||
):
|
||||
paren = await cg.get_variable(config[CONF_ID])
|
||||
return cg.new_Pvariable(condition_id, template_arg, paren)
|
||||
|
||||
|
||||
@coroutine_with_priority(CoroPriority.CORE)
|
||||
|
||||
@@ -655,7 +655,7 @@ async def to_code(config):
|
||||
cg.add_global(binary_sensor_ns.using)
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
automation.register_simple_action(
|
||||
"binary_sensor.invalidate_state",
|
||||
BinarySensorInvalidateAction,
|
||||
cv.maybe_simple_value(
|
||||
@@ -666,9 +666,6 @@ async def to_code(config):
|
||||
),
|
||||
synchronous=True,
|
||||
)
|
||||
async def binary_sensor_invalidate_state_to_code(config, action_id, template_arg, args):
|
||||
paren = await cg.get_variable(config[CONF_ID])
|
||||
return cg.new_Pvariable(action_id, template_arg, paren)
|
||||
|
||||
|
||||
# automation.cpp only implements the click/double_click/multi_click triggers
|
||||
|
||||
@@ -32,8 +32,6 @@ from esphome.const import (
|
||||
UNIT_VOLT,
|
||||
UNIT_WATT,
|
||||
)
|
||||
from esphome.core import ID
|
||||
from esphome.cpp_generator import MockObj, TemplateArgsType
|
||||
from esphome.types import ConfigType
|
||||
|
||||
# Import ICONS not included in esphome's const.py, from the local components const.py
|
||||
@@ -138,7 +136,7 @@ FINAL_VALIDATE_SCHEMA = uart.final_validate_device_schema(
|
||||
)
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
automation.register_parented_action(
|
||||
"bl0906.reset_energy",
|
||||
ResetEnergyAction,
|
||||
maybe_simple_id(
|
||||
@@ -148,15 +146,6 @@ FINAL_VALIDATE_SCHEMA = uart.final_validate_device_schema(
|
||||
),
|
||||
synchronous=True,
|
||||
)
|
||||
async def reset_energy_to_code(
|
||||
config: ConfigType,
|
||||
action_id: ID,
|
||||
template_arg: cg.TemplateArguments,
|
||||
args: TemplateArgsType,
|
||||
) -> MockObj:
|
||||
var = cg.new_Pvariable(action_id, template_arg)
|
||||
await cg.register_parented(var, config[CONF_ID])
|
||||
return var
|
||||
|
||||
|
||||
async def to_code(config: ConfigType) -> None:
|
||||
|
||||
@@ -207,26 +207,20 @@ BLE_REMOVE_BOND_ACTION_SCHEMA = cv.Schema(
|
||||
)
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
automation.register_simple_action(
|
||||
"ble_client.disconnect",
|
||||
BLEDisconnectAction,
|
||||
BLE_CONNECT_ACTION_SCHEMA,
|
||||
synchronous=False,
|
||||
)
|
||||
async def ble_disconnect_to_code(config, action_id, template_arg, args):
|
||||
parent = await cg.get_variable(config[CONF_ID])
|
||||
return cg.new_Pvariable(action_id, template_arg, parent)
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
automation.register_simple_action(
|
||||
"ble_client.connect",
|
||||
BLEConnectAction,
|
||||
BLE_CONNECT_ACTION_SCHEMA,
|
||||
synchronous=False,
|
||||
)
|
||||
async def ble_connect_to_code(config, action_id, template_arg, args):
|
||||
parent = await cg.get_variable(config[CONF_ID])
|
||||
return cg.new_Pvariable(action_id, template_arg, parent)
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
@@ -328,15 +322,12 @@ async def passkey_reply_to_code(config, action_id, template_arg, args):
|
||||
return var
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
automation.register_simple_action(
|
||||
"ble_client.remove_bond",
|
||||
BLERemoveBondAction,
|
||||
BLE_REMOVE_BOND_ACTION_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
async def remove_bond_to_code(config, action_id, template_arg, args):
|
||||
parent = await cg.get_variable(config[CONF_ID])
|
||||
return cg.new_Pvariable(action_id, template_arg, parent)
|
||||
|
||||
|
||||
async def to_code(config):
|
||||
|
||||
@@ -28,7 +28,7 @@ CONFIG_SCHEMA = (
|
||||
)
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
automation.register_parented_action(
|
||||
"bm8563.write_time",
|
||||
WriteAction,
|
||||
automation.maybe_simple_id(
|
||||
@@ -38,15 +38,6 @@ CONFIG_SCHEMA = (
|
||||
),
|
||||
synchronous=True,
|
||||
)
|
||||
async def bm8563_write_time_to_code(
|
||||
config: ConfigType,
|
||||
action_id: ID,
|
||||
template_arg: cg.TemplateArguments,
|
||||
args: TemplateArgsType,
|
||||
) -> MockObj:
|
||||
var = cg.new_Pvariable(action_id, template_arg)
|
||||
await cg.register_parented(var, config[CONF_ID])
|
||||
return var
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
@@ -73,7 +64,7 @@ async def bm8563_start_timer_to_code(
|
||||
return var
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
automation.register_parented_action(
|
||||
"bm8563.read_time",
|
||||
ReadAction,
|
||||
automation.maybe_simple_id(
|
||||
@@ -83,15 +74,6 @@ async def bm8563_start_timer_to_code(
|
||||
),
|
||||
synchronous=True,
|
||||
)
|
||||
async def bm8563_read_time_to_code(
|
||||
config: ConfigType,
|
||||
action_id: ID,
|
||||
template_arg: cg.TemplateArguments,
|
||||
args: TemplateArgsType,
|
||||
) -> MockObj:
|
||||
var = cg.new_Pvariable(action_id, template_arg)
|
||||
await cg.register_parented(var, config[CONF_ID])
|
||||
return var
|
||||
|
||||
|
||||
async def to_code(config: ConfigType) -> None:
|
||||
|
||||
@@ -364,22 +364,36 @@ CC1101_ACTION_SCHEMA = cv.Schema(
|
||||
)
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
"cc1101.begin_tx", BeginTxAction, CC1101_ACTION_SCHEMA, synchronous=True
|
||||
automation.register_parented_action(
|
||||
"cc1101.begin_tx",
|
||||
BeginTxAction,
|
||||
CC1101_ACTION_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
@automation.register_action(
|
||||
"cc1101.begin_rx", BeginRxAction, CC1101_ACTION_SCHEMA, synchronous=True
|
||||
|
||||
|
||||
automation.register_parented_action(
|
||||
"cc1101.begin_rx",
|
||||
BeginRxAction,
|
||||
CC1101_ACTION_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
@automation.register_action(
|
||||
"cc1101.reset", ResetAction, CC1101_ACTION_SCHEMA, synchronous=True
|
||||
|
||||
|
||||
automation.register_parented_action(
|
||||
"cc1101.reset",
|
||||
ResetAction,
|
||||
CC1101_ACTION_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
@automation.register_action(
|
||||
"cc1101.set_idle", SetIdleAction, CC1101_ACTION_SCHEMA, synchronous=True
|
||||
|
||||
|
||||
automation.register_parented_action(
|
||||
"cc1101.set_idle",
|
||||
SetIdleAction,
|
||||
CC1101_ACTION_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
async def cc1101_action_to_code(config, action_id, template_arg, args):
|
||||
var = cg.new_Pvariable(action_id, template_arg)
|
||||
await cg.register_parented(var, config[CONF_ID])
|
||||
return var
|
||||
|
||||
|
||||
def validate_raw_data(value):
|
||||
|
||||
@@ -13,8 +13,6 @@ from esphome.const import (
|
||||
STATE_CLASS_MEASUREMENT,
|
||||
UNIT_PARTS_PER_MILLION,
|
||||
)
|
||||
from esphome.core import ID
|
||||
from esphome.cpp_generator import MockObj, TemplateArgsType
|
||||
from esphome.types import ConfigType
|
||||
|
||||
DEPENDENCIES = ["uart"]
|
||||
@@ -72,18 +70,9 @@ CALIBRATION_ACTION_SCHEMA = maybe_simple_id(
|
||||
)
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
automation.register_simple_action(
|
||||
"cm1106.calibrate_zero",
|
||||
CM1106CalibrateZeroAction,
|
||||
CALIBRATION_ACTION_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
async def cm1106_calibration_to_code(
|
||||
config: ConfigType,
|
||||
action_id: ID,
|
||||
template_arg: cg.TemplateArguments,
|
||||
args: TemplateArgsType,
|
||||
) -> MockObj:
|
||||
"""Service code generation entry point."""
|
||||
paren = await cg.get_variable(config[CONF_ID])
|
||||
return cg.new_Pvariable(action_id, template_arg, paren)
|
||||
|
||||
@@ -17,8 +17,6 @@ from esphome.const import (
|
||||
UNIT_VOLT,
|
||||
UNIT_WATT,
|
||||
)
|
||||
from esphome.core import ID
|
||||
from esphome.cpp_generator import MockObj, TemplateArgsType
|
||||
from esphome.types import ConfigType
|
||||
|
||||
CODEOWNERS = ["@balrog-kun"]
|
||||
@@ -131,7 +129,7 @@ async def to_code(config: ConfigType) -> None:
|
||||
cg.add(var.set_power_sensor(sens))
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
automation.register_simple_action(
|
||||
"cs5460a.restart",
|
||||
CS5460ARestartAction,
|
||||
maybe_simple_id(
|
||||
@@ -141,11 +139,3 @@ async def to_code(config: ConfigType) -> None:
|
||||
),
|
||||
synchronous=True,
|
||||
)
|
||||
async def restart_action_to_code(
|
||||
config: ConfigType,
|
||||
action_id: ID,
|
||||
template_arg: cg.TemplateArguments,
|
||||
args: TemplateArgsType,
|
||||
) -> MockObj:
|
||||
paren = await cg.get_variable(config[CONF_ID])
|
||||
return cg.new_Pvariable(action_id, template_arg, paren)
|
||||
|
||||
@@ -199,7 +199,7 @@ automation.register_apply_action(
|
||||
)
|
||||
|
||||
|
||||
@automation.register_condition(
|
||||
automation.register_parented_condition(
|
||||
"dfplayer.is_playing",
|
||||
DFPlayerIsPlayingCondition,
|
||||
cv.Schema(
|
||||
@@ -208,7 +208,3 @@ automation.register_apply_action(
|
||||
}
|
||||
),
|
||||
)
|
||||
async def dfplayer_is_playing_to_code(config, condition_id, template_arg, args):
|
||||
var = cg.new_Pvariable(condition_id, template_arg)
|
||||
await cg.register_parented(var, config[CONF_ID])
|
||||
return var
|
||||
|
||||
@@ -49,7 +49,7 @@ async def to_code(config: ConfigType) -> None:
|
||||
await uart.register_uart_device(var, config)
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
automation.register_parented_action(
|
||||
"dfrobot_sen0395.reset",
|
||||
DfrobotSen0395ResetAction,
|
||||
maybe_simple_id(
|
||||
@@ -59,16 +59,6 @@ async def to_code(config: ConfigType) -> None:
|
||||
),
|
||||
synchronous=True,
|
||||
)
|
||||
async def dfrobot_sen0395_reset_to_code(
|
||||
config: ConfigType,
|
||||
action_id: ID,
|
||||
template_arg: cg.TemplateArguments,
|
||||
args: TemplateArgsType,
|
||||
) -> MockObj:
|
||||
var = cg.new_Pvariable(action_id, template_arg)
|
||||
await cg.register_parented(var, config[CONF_ID])
|
||||
|
||||
return var
|
||||
|
||||
|
||||
def range_segment_list(input: Any) -> list:
|
||||
|
||||
@@ -294,74 +294,71 @@ MENU_ACTION_SCHEMA = maybe_simple_id(
|
||||
)
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
"display_menu.up", UpAction, MENU_ACTION_SCHEMA, synchronous=True
|
||||
automation.register_simple_action(
|
||||
"display_menu.up",
|
||||
UpAction,
|
||||
MENU_ACTION_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
async def menu_up_to_code(config, action_id, template_arg, args):
|
||||
paren = await cg.get_variable(config[CONF_ID])
|
||||
return cg.new_Pvariable(action_id, template_arg, paren)
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
"display_menu.down", DownAction, MENU_ACTION_SCHEMA, synchronous=True
|
||||
automation.register_simple_action(
|
||||
"display_menu.down",
|
||||
DownAction,
|
||||
MENU_ACTION_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
async def menu_down_to_code(config, action_id, template_arg, args):
|
||||
paren = await cg.get_variable(config[CONF_ID])
|
||||
return cg.new_Pvariable(action_id, template_arg, paren)
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
"display_menu.left", LeftAction, MENU_ACTION_SCHEMA, synchronous=True
|
||||
automation.register_simple_action(
|
||||
"display_menu.left",
|
||||
LeftAction,
|
||||
MENU_ACTION_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
async def menu_left_to_code(config, action_id, template_arg, args):
|
||||
paren = await cg.get_variable(config[CONF_ID])
|
||||
return cg.new_Pvariable(action_id, template_arg, paren)
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
"display_menu.right", RightAction, MENU_ACTION_SCHEMA, synchronous=True
|
||||
automation.register_simple_action(
|
||||
"display_menu.right",
|
||||
RightAction,
|
||||
MENU_ACTION_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
async def menu_right_to_code(config, action_id, template_arg, args):
|
||||
paren = await cg.get_variable(config[CONF_ID])
|
||||
return cg.new_Pvariable(action_id, template_arg, paren)
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
"display_menu.enter", EnterAction, MENU_ACTION_SCHEMA, synchronous=True
|
||||
automation.register_simple_action(
|
||||
"display_menu.enter",
|
||||
EnterAction,
|
||||
MENU_ACTION_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
async def menu_enter_to_code(config, action_id, template_arg, args):
|
||||
paren = await cg.get_variable(config[CONF_ID])
|
||||
return cg.new_Pvariable(action_id, template_arg, paren)
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
"display_menu.show", ShowAction, MENU_ACTION_SCHEMA, synchronous=True
|
||||
automation.register_simple_action(
|
||||
"display_menu.show",
|
||||
ShowAction,
|
||||
MENU_ACTION_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
async def menu_show_to_code(config, action_id, template_arg, args):
|
||||
paren = await cg.get_variable(config[CONF_ID])
|
||||
return cg.new_Pvariable(action_id, template_arg, paren)
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
"display_menu.hide", HideAction, MENU_ACTION_SCHEMA, synchronous=True
|
||||
automation.register_simple_action(
|
||||
"display_menu.hide",
|
||||
HideAction,
|
||||
MENU_ACTION_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
async def menu_hide_to_code(config, action_id, template_arg, args):
|
||||
paren = await cg.get_variable(config[CONF_ID])
|
||||
return cg.new_Pvariable(action_id, template_arg, paren)
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
automation.register_simple_action(
|
||||
"display_menu.show_main",
|
||||
ShowMainAction,
|
||||
MENU_ACTION_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
async def menu_show_main_to_code(config, action_id, template_arg, args):
|
||||
paren = await cg.get_variable(config[CONF_ID])
|
||||
return cg.new_Pvariable(action_id, template_arg, paren)
|
||||
|
||||
|
||||
@automation.register_condition(
|
||||
automation.register_simple_condition(
|
||||
"display_menu.is_active",
|
||||
IsActiveCondition,
|
||||
automation.maybe_simple_id(
|
||||
@@ -370,9 +367,6 @@ async def menu_show_main_to_code(config, action_id, template_arg, args):
|
||||
}
|
||||
),
|
||||
)
|
||||
async def display_menu_is_active_to_code(config, condition_id, template_arg, args):
|
||||
paren = await cg.get_variable(config[CONF_ID])
|
||||
return cg.new_Pvariable(condition_id, template_arg, paren)
|
||||
|
||||
|
||||
async def menu_item_to_code(menu, config, parent):
|
||||
|
||||
@@ -3,8 +3,6 @@ import esphome.codegen as cg
|
||||
from esphome.components import i2c, time
|
||||
import esphome.config_validation as cv
|
||||
from esphome.const import CONF_ID
|
||||
from esphome.core import ID
|
||||
from esphome.cpp_generator import MockObj, TemplateArgsType
|
||||
from esphome.types import ConfigType
|
||||
|
||||
CODEOWNERS = ["@badbadc0ffee"]
|
||||
@@ -22,7 +20,7 @@ CONFIG_SCHEMA = time.TIME_SCHEMA.extend(
|
||||
).extend(i2c.i2c_device_schema(0x68))
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
automation.register_parented_action(
|
||||
"ds1307.write_time",
|
||||
WriteAction,
|
||||
cv.Schema(
|
||||
@@ -32,18 +30,9 @@ CONFIG_SCHEMA = time.TIME_SCHEMA.extend(
|
||||
),
|
||||
synchronous=True,
|
||||
)
|
||||
async def ds1307_write_time_to_code(
|
||||
config: ConfigType,
|
||||
action_id: ID,
|
||||
template_arg: cg.TemplateArguments,
|
||||
args: TemplateArgsType,
|
||||
) -> MockObj:
|
||||
var = cg.new_Pvariable(action_id, template_arg)
|
||||
await cg.register_parented(var, config[CONF_ID])
|
||||
return var
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
automation.register_parented_action(
|
||||
"ds1307.read_time",
|
||||
ReadAction,
|
||||
automation.maybe_simple_id(
|
||||
@@ -53,15 +42,6 @@ async def ds1307_write_time_to_code(
|
||||
),
|
||||
synchronous=True,
|
||||
)
|
||||
async def ds1307_read_time_to_code(
|
||||
config: ConfigType,
|
||||
action_id: ID,
|
||||
template_arg: cg.TemplateArguments,
|
||||
args: TemplateArgsType,
|
||||
) -> MockObj:
|
||||
var = cg.new_Pvariable(action_id, template_arg)
|
||||
await cg.register_parented(var, config[CONF_ID])
|
||||
return var
|
||||
|
||||
|
||||
async def to_code(config: ConfigType) -> None:
|
||||
|
||||
@@ -1,10 +1,5 @@
|
||||
from esphome.automation import (
|
||||
Action,
|
||||
Condition,
|
||||
maybe_simple_id,
|
||||
register_action,
|
||||
register_condition,
|
||||
)
|
||||
from esphome import automation
|
||||
from esphome.automation import Action, Condition, maybe_simple_id, register_condition
|
||||
import esphome.codegen as cg
|
||||
from esphome.components import binary_sensor, sensor
|
||||
import esphome.config_validation as cv
|
||||
@@ -93,46 +88,28 @@ DUTY_TIME_ID_SCHEMA = maybe_simple_id(
|
||||
)
|
||||
|
||||
|
||||
@register_action(
|
||||
"sensor.duty_time.start", StartAction, DUTY_TIME_ID_SCHEMA, synchronous=True
|
||||
automation.register_parented_action(
|
||||
"sensor.duty_time.start",
|
||||
StartAction,
|
||||
DUTY_TIME_ID_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
async def sensor_runtime_start_to_code(
|
||||
config: ConfigType,
|
||||
action_id: ID,
|
||||
template_arg: cg.TemplateArguments,
|
||||
args: TemplateArgsType,
|
||||
) -> MockObj:
|
||||
var = cg.new_Pvariable(action_id, template_arg)
|
||||
await cg.register_parented(var, config[CONF_ID])
|
||||
return var
|
||||
|
||||
|
||||
@register_action(
|
||||
"sensor.duty_time.stop", StopAction, DUTY_TIME_ID_SCHEMA, synchronous=True
|
||||
automation.register_parented_action(
|
||||
"sensor.duty_time.stop",
|
||||
StopAction,
|
||||
DUTY_TIME_ID_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
async def sensor_runtime_stop_to_code(
|
||||
config: ConfigType,
|
||||
action_id: ID,
|
||||
template_arg: cg.TemplateArguments,
|
||||
args: TemplateArgsType,
|
||||
) -> MockObj:
|
||||
var = cg.new_Pvariable(action_id, template_arg)
|
||||
await cg.register_parented(var, config[CONF_ID])
|
||||
return var
|
||||
|
||||
|
||||
@register_action(
|
||||
"sensor.duty_time.reset", ResetAction, DUTY_TIME_ID_SCHEMA, synchronous=True
|
||||
automation.register_parented_action(
|
||||
"sensor.duty_time.reset",
|
||||
ResetAction,
|
||||
DUTY_TIME_ID_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
async def sensor_runtime_reset_to_code(
|
||||
config: ConfigType,
|
||||
action_id: ID,
|
||||
template_arg: cg.TemplateArguments,
|
||||
args: TemplateArgsType,
|
||||
) -> MockObj:
|
||||
var = cg.new_Pvariable(action_id, template_arg)
|
||||
await cg.register_parented(var, config[CONF_ID])
|
||||
return var
|
||||
|
||||
|
||||
@register_condition(
|
||||
|
||||
@@ -32,8 +32,7 @@ from esphome.const import (
|
||||
CONF_NAME,
|
||||
CONF_NAME_ADD_MAC_SUFFIX,
|
||||
)
|
||||
from esphome.core import CORE, ID, TimePeriod
|
||||
from esphome.cpp_generator import MockObj, TemplateArgsType
|
||||
from esphome.core import CORE, TimePeriod
|
||||
import esphome.final_validate as fv
|
||||
from esphome.types import ConfigType
|
||||
|
||||
@@ -606,38 +605,27 @@ async def to_code(config: ConfigType) -> None:
|
||||
cg.add_define("USE_ESP32_BLE_UUID")
|
||||
|
||||
|
||||
@automation.register_condition("ble.enabled", BLEEnabledCondition, cv.Schema({}))
|
||||
async def ble_enabled_to_code(
|
||||
config: ConfigType,
|
||||
condition_id: ID,
|
||||
template_arg: cg.TemplateArguments,
|
||||
args: TemplateArgsType,
|
||||
) -> MockObj:
|
||||
return cg.new_Pvariable(condition_id, template_arg)
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
"ble.enable", BLEEnableAction, cv.Schema({}), synchronous=True
|
||||
automation.register_bare_condition(
|
||||
"ble.enabled",
|
||||
BLEEnabledCondition,
|
||||
cv.Schema({}),
|
||||
)
|
||||
async def ble_enable_to_code(
|
||||
config: ConfigType,
|
||||
action_id: ID,
|
||||
template_arg: cg.TemplateArguments,
|
||||
args: TemplateArgsType,
|
||||
) -> MockObj:
|
||||
return cg.new_Pvariable(action_id, template_arg)
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
"ble.disable", BLEDisableAction, cv.Schema({}), synchronous=True
|
||||
automation.register_bare_action(
|
||||
"ble.enable",
|
||||
BLEEnableAction,
|
||||
cv.Schema({}),
|
||||
synchronous=True,
|
||||
)
|
||||
|
||||
|
||||
automation.register_bare_action(
|
||||
"ble.disable",
|
||||
BLEDisableAction,
|
||||
cv.Schema({}),
|
||||
synchronous=True,
|
||||
)
|
||||
async def ble_disable_to_code(
|
||||
config: ConfigType,
|
||||
action_id: ID,
|
||||
template_arg: cg.TemplateArguments,
|
||||
args: TemplateArgsType,
|
||||
) -> MockObj:
|
||||
return cg.new_Pvariable(action_id, template_arg)
|
||||
|
||||
|
||||
# ble_advertising.cpp is fully #ifdef'd on USE_ESP32_BLE_ADVERTISING, set
|
||||
|
||||
@@ -53,12 +53,10 @@ from esphome.const import (
|
||||
)
|
||||
from esphome.core import (
|
||||
CORE,
|
||||
ID,
|
||||
CoroPriority,
|
||||
TimePeriodMilliseconds,
|
||||
coroutine_with_priority,
|
||||
)
|
||||
from esphome.cpp_generator import MockObj, TemplateArgsType
|
||||
import esphome.final_validate as fv
|
||||
from esphome.types import ConfigType
|
||||
|
||||
@@ -924,24 +922,15 @@ def _filter_source_files() -> list[str]:
|
||||
FILTER_SOURCE_FILES = _filter_source_files
|
||||
|
||||
|
||||
async def _new_pvariable_to_code(
|
||||
config: ConfigType,
|
||||
id_: ID,
|
||||
template_arg: cg.TemplateArguments,
|
||||
args: TemplateArgsType,
|
||||
) -> MockObj:
|
||||
return cg.new_Pvariable(id_, template_arg)
|
||||
|
||||
|
||||
for _name, _cls in (
|
||||
("ethernet.connected", EthernetConnectedCondition),
|
||||
("ethernet.enabled", EthernetEnabledCondition),
|
||||
):
|
||||
automation.register_condition(_name, _cls, cv.Schema({}))(_new_pvariable_to_code)
|
||||
for _name, _cls in (
|
||||
("ethernet.enable", EthernetEnableAction),
|
||||
("ethernet.disable", EthernetDisableAction),
|
||||
):
|
||||
automation.register_action(_name, _cls, cv.Schema({}), synchronous=True)(
|
||||
_new_pvariable_to_code
|
||||
)
|
||||
automation.register_bare_condition(
|
||||
"ethernet.connected", EthernetConnectedCondition, cv.Schema({})
|
||||
)
|
||||
automation.register_bare_condition(
|
||||
"ethernet.enabled", EthernetEnabledCondition, cv.Schema({})
|
||||
)
|
||||
automation.register_bare_action(
|
||||
"ethernet.enable", EthernetEnableAction, cv.Schema({}), synchronous=True
|
||||
)
|
||||
automation.register_bare_action(
|
||||
"ethernet.disable", EthernetDisableAction, cv.Schema({}), synchronous=True
|
||||
)
|
||||
|
||||
@@ -80,72 +80,52 @@ EzoPMPArbitraryCommandAction = ezo_pmp_ns.class_(
|
||||
)
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
automation.register_simple_action(
|
||||
"ezo_pmp.find",
|
||||
EzoPMPFindAction,
|
||||
EZO_PMP_NO_ARGS_ACTION_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
async def ezo_pmp_find_to_code(config, action_id, template_arg, args):
|
||||
paren = await cg.get_variable(config[CONF_ID])
|
||||
return cg.new_Pvariable(action_id, template_arg, paren)
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
automation.register_simple_action(
|
||||
"ezo_pmp.dose_continuously",
|
||||
EzoPMPDoseContinuouslyAction,
|
||||
EZO_PMP_NO_ARGS_ACTION_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
async def ezo_pmp_dose_continuously_to_code(config, action_id, template_arg, args):
|
||||
paren = await cg.get_variable(config[CONF_ID])
|
||||
return cg.new_Pvariable(action_id, template_arg, paren)
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
automation.register_simple_action(
|
||||
"ezo_pmp.clear_total_volume_dosed",
|
||||
EzoPMPClearTotalVolumeDispensedAction,
|
||||
EZO_PMP_NO_ARGS_ACTION_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
async def ezo_pmp_clear_total_volume_dosed_to_code(
|
||||
config, action_id, template_arg, args
|
||||
):
|
||||
paren = await cg.get_variable(config[CONF_ID])
|
||||
return cg.new_Pvariable(action_id, template_arg, paren)
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
automation.register_simple_action(
|
||||
"ezo_pmp.clear_calibration",
|
||||
EzoPMPClearCalibrationAction,
|
||||
EZO_PMP_NO_ARGS_ACTION_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
async def ezo_pmp_clear_calibration_to_code(config, action_id, template_arg, args):
|
||||
paren = await cg.get_variable(config[CONF_ID])
|
||||
return cg.new_Pvariable(action_id, template_arg, paren)
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
automation.register_simple_action(
|
||||
"ezo_pmp.pause_dosing",
|
||||
EzoPMPPauseDosingAction,
|
||||
EZO_PMP_NO_ARGS_ACTION_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
async def ezo_pmp_pause_dosing_to_code(config, action_id, template_arg, args):
|
||||
paren = await cg.get_variable(config[CONF_ID])
|
||||
return cg.new_Pvariable(action_id, template_arg, paren)
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
automation.register_simple_action(
|
||||
"ezo_pmp.stop_dosing",
|
||||
EzoPMPStopDosingAction,
|
||||
EZO_PMP_NO_ARGS_ACTION_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
async def ezo_pmp_stop_dosing_to_code(config, action_id, template_arg, args):
|
||||
paren = await cg.get_variable(config[CONF_ID])
|
||||
return cg.new_Pvariable(action_id, template_arg, paren)
|
||||
|
||||
|
||||
# Actions that require Multiple Args
|
||||
|
||||
@@ -206,7 +206,7 @@ async def fingerprint_grow_enroll_to_code(config, action_id, template_arg, args)
|
||||
return var
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
automation.register_parented_action(
|
||||
"fingerprint_grow.cancel_enroll",
|
||||
CancelEnrollmentAction,
|
||||
cv.Schema(
|
||||
@@ -216,10 +216,6 @@ async def fingerprint_grow_enroll_to_code(config, action_id, template_arg, args)
|
||||
),
|
||||
synchronous=True,
|
||||
)
|
||||
async def fingerprint_grow_cancel_enroll_to_code(config, action_id, template_arg, args):
|
||||
var = cg.new_Pvariable(action_id, template_arg)
|
||||
await cg.register_parented(var, config[CONF_ID])
|
||||
return var
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
@@ -243,7 +239,7 @@ async def fingerprint_grow_delete_to_code(config, action_id, template_arg, args)
|
||||
return var
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
automation.register_parented_action(
|
||||
"fingerprint_grow.delete_all",
|
||||
DeleteAllAction,
|
||||
cv.Schema(
|
||||
@@ -253,10 +249,6 @@ async def fingerprint_grow_delete_to_code(config, action_id, template_arg, args)
|
||||
),
|
||||
synchronous=True,
|
||||
)
|
||||
async def fingerprint_grow_delete_all_to_code(config, action_id, template_arg, args):
|
||||
var = cg.new_Pvariable(action_id, template_arg)
|
||||
await cg.register_parented(var, config[CONF_ID])
|
||||
return var
|
||||
|
||||
|
||||
FINGERPRINT_GROW_LED_CONTROL_ACTION_SCHEMA = cv.maybe_simple_value(
|
||||
|
||||
@@ -126,7 +126,7 @@ async def grove_tb6612fng_stop_to_code(config, action_id, template_arg, args):
|
||||
return var
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
automation.register_parented_action(
|
||||
"grove_tb6612fng.standby",
|
||||
GROVETB6612FNGMotorStandbyAction,
|
||||
cv.Schema(
|
||||
@@ -136,14 +136,9 @@ async def grove_tb6612fng_stop_to_code(config, action_id, template_arg, args):
|
||||
),
|
||||
synchronous=True,
|
||||
)
|
||||
async def grove_tb6612fng_standby_to_code(config, action_id, template_arg, args):
|
||||
var = cg.new_Pvariable(action_id, template_arg)
|
||||
await cg.register_parented(var, config[CONF_ID])
|
||||
|
||||
return var
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
automation.register_parented_action(
|
||||
"grove_tb6612fng.no_standby",
|
||||
GROVETB6612FNGMotorNoStandbyAction,
|
||||
cv.Schema(
|
||||
@@ -153,11 +148,6 @@ async def grove_tb6612fng_standby_to_code(config, action_id, template_arg, args)
|
||||
),
|
||||
synchronous=True,
|
||||
)
|
||||
async def grove_tb6612fng_no_standby_to_code(config, action_id, template_arg, args):
|
||||
var = cg.new_Pvariable(action_id, template_arg)
|
||||
await cg.register_parented(var, config[CONF_ID])
|
||||
|
||||
return var
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
|
||||
@@ -284,56 +284,53 @@ HAIER_HON_BASE_ACTION_SCHEMA = automation.maybe_simple_id(
|
||||
)
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
automation.register_simple_action(
|
||||
"climate.haier.display_on",
|
||||
DisplayOnAction,
|
||||
HAIER_BASE_ACTION_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
@automation.register_action(
|
||||
|
||||
|
||||
automation.register_simple_action(
|
||||
"climate.haier.display_off",
|
||||
DisplayOffAction,
|
||||
HAIER_BASE_ACTION_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
async def display_action_to_code(config, action_id, template_arg, args):
|
||||
paren = await cg.get_variable(config[CONF_ID])
|
||||
return cg.new_Pvariable(action_id, template_arg, paren)
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
automation.register_simple_action(
|
||||
"climate.haier.beeper_on",
|
||||
BeeperOnAction,
|
||||
HAIER_HON_BASE_ACTION_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
@automation.register_action(
|
||||
|
||||
|
||||
automation.register_simple_action(
|
||||
"climate.haier.beeper_off",
|
||||
BeeperOffAction,
|
||||
HAIER_HON_BASE_ACTION_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
async def beeper_action_to_code(config, action_id, template_arg, args):
|
||||
paren = await cg.get_variable(config[CONF_ID])
|
||||
return cg.new_Pvariable(action_id, template_arg, paren)
|
||||
|
||||
|
||||
# Start self cleaning or steri-cleaning action action
|
||||
@automation.register_action(
|
||||
automation.register_simple_action(
|
||||
"climate.haier.start_self_cleaning",
|
||||
StartSelfCleaningAction,
|
||||
HAIER_HON_BASE_ACTION_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
@automation.register_action(
|
||||
|
||||
|
||||
automation.register_simple_action(
|
||||
"climate.haier.start_steri_cleaning",
|
||||
StartSteriCleaningAction,
|
||||
HAIER_HON_BASE_ACTION_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
async def start_cleaning_to_code(config, action_id, template_arg, args):
|
||||
paren = await cg.get_variable(config[CONF_ID])
|
||||
return cg.new_Pvariable(action_id, template_arg, paren)
|
||||
|
||||
|
||||
# Set vertical airflow direction action
|
||||
@@ -384,44 +381,44 @@ async def haier_set_horizontal_airflow_to_code(config, action_id, template_arg,
|
||||
return var
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
automation.register_simple_action(
|
||||
"climate.haier.health_on",
|
||||
HealthOnAction,
|
||||
HAIER_BASE_ACTION_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
@automation.register_action(
|
||||
|
||||
|
||||
automation.register_simple_action(
|
||||
"climate.haier.health_off",
|
||||
HealthOffAction,
|
||||
HAIER_BASE_ACTION_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
async def health_action_to_code(config, action_id, template_arg, args):
|
||||
paren = await cg.get_variable(config[CONF_ID])
|
||||
return cg.new_Pvariable(action_id, template_arg, paren)
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
automation.register_simple_action(
|
||||
"climate.haier.power_on",
|
||||
PowerOnAction,
|
||||
HAIER_BASE_ACTION_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
@automation.register_action(
|
||||
|
||||
|
||||
automation.register_simple_action(
|
||||
"climate.haier.power_off",
|
||||
PowerOffAction,
|
||||
HAIER_BASE_ACTION_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
@automation.register_action(
|
||||
|
||||
|
||||
automation.register_simple_action(
|
||||
"climate.haier.power_toggle",
|
||||
PowerToggleAction,
|
||||
HAIER_BASE_ACTION_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
async def power_action_to_code(config, action_id, template_arg, args):
|
||||
paren = await cg.get_variable(config[CONF_ID])
|
||||
return cg.new_Pvariable(action_id, template_arg, paren)
|
||||
|
||||
|
||||
def _final_validate(config) -> None:
|
||||
|
||||
@@ -7,14 +7,11 @@ import esphome.config_validation as cv
|
||||
from esphome.const import (
|
||||
CONF_DECAY_MODE,
|
||||
CONF_ENABLE_PIN,
|
||||
CONF_ID,
|
||||
CONF_PIN_A,
|
||||
CONF_PIN_B,
|
||||
CONF_PRESET_MODES,
|
||||
CONF_SPEED_COUNT,
|
||||
)
|
||||
from esphome.core import ID
|
||||
from esphome.cpp_generator import MockObj, TemplateArgsType
|
||||
from esphome.types import ConfigType
|
||||
|
||||
from .. import hbridge_ns
|
||||
@@ -51,20 +48,12 @@ CONFIG_SCHEMA = (
|
||||
)
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
automation.register_simple_action(
|
||||
"fan.hbridge.brake",
|
||||
BrakeAction,
|
||||
maybe_simple_id({cv.GenerateID(): cv.use_id(HBridgeFan)}),
|
||||
synchronous=True,
|
||||
)
|
||||
async def fan_hbridge_brake_to_code(
|
||||
config: ConfigType,
|
||||
action_id: ID,
|
||||
template_arg: cg.TemplateArguments,
|
||||
args: TemplateArgsType,
|
||||
) -> MockObj:
|
||||
paren = await cg.get_variable(config[CONF_ID])
|
||||
return cg.new_Pvariable(action_id, template_arg, paren)
|
||||
|
||||
|
||||
async def to_code(config: ConfigType) -> None:
|
||||
|
||||
@@ -139,18 +139,9 @@ async def hdc302x_heater_on_to_code(
|
||||
return var
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
automation.register_parented_action(
|
||||
"hdc302x.heater_off",
|
||||
HeaterOffAction,
|
||||
HDC302X_ACTION_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
async def hdc302x_heater_off_to_code(
|
||||
config: ConfigType,
|
||||
action_id: ID,
|
||||
template_arg: cg.TemplateArguments,
|
||||
args: TemplateArgsType,
|
||||
) -> MockObj:
|
||||
var = cg.new_Pvariable(action_id, template_arg)
|
||||
await cg.register_parented(var, config[CONF_ID])
|
||||
return var
|
||||
|
||||
@@ -106,7 +106,7 @@ async def to_code(config: ConfigType) -> None:
|
||||
cg.add(var.set_restore(config[CONF_RESTORE]))
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
automation.register_parented_action(
|
||||
"sensor.integration.reset",
|
||||
ResetAction,
|
||||
automation.maybe_simple_id(
|
||||
@@ -116,15 +116,6 @@ async def to_code(config: ConfigType) -> None:
|
||||
),
|
||||
synchronous=True,
|
||||
)
|
||||
async def sensor_integration_reset_to_code(
|
||||
config: ConfigType,
|
||||
action_id: ID,
|
||||
template_arg: cg.TemplateArguments,
|
||||
args: TemplateArgsType,
|
||||
) -> MockObj:
|
||||
var = cg.new_Pvariable(action_id, template_arg)
|
||||
await cg.register_parented(var, config[CONF_ID])
|
||||
return var
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
|
||||
@@ -15,7 +15,6 @@ from esphome.const import (
|
||||
CONF_TIMEOUT,
|
||||
CONF_TRIGGER_ID,
|
||||
)
|
||||
from esphome.core import ID
|
||||
from esphome.cpp_generator import MockObj, literal
|
||||
from esphome.types import ConfigType, TemplateArgsType
|
||||
|
||||
@@ -135,7 +134,7 @@ async def to_code(config: ConfigType) -> None:
|
||||
cg.add(var.set_enabled(config[CONF_ENABLE_ON_BOOT]))
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
automation.register_parented_action(
|
||||
"key_collector.enable",
|
||||
EnableAction,
|
||||
automation.maybe_simple_id(
|
||||
@@ -145,18 +144,9 @@ async def to_code(config: ConfigType) -> None:
|
||||
),
|
||||
synchronous=True,
|
||||
)
|
||||
async def enable_to_code(
|
||||
config: ConfigType,
|
||||
action_id: ID,
|
||||
template_arg: cg.TemplateArguments,
|
||||
args: TemplateArgsType,
|
||||
) -> MockObj:
|
||||
var = cg.new_Pvariable(action_id, template_arg)
|
||||
await cg.register_parented(var, config[CONF_ID])
|
||||
return var
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
automation.register_parented_action(
|
||||
"key_collector.disable",
|
||||
DisableAction,
|
||||
automation.maybe_simple_id(
|
||||
@@ -166,12 +156,3 @@ async def enable_to_code(
|
||||
),
|
||||
synchronous=True,
|
||||
)
|
||||
async def disable_to_code(
|
||||
config: ConfigType,
|
||||
action_id: ID,
|
||||
template_arg: cg.TemplateArguments,
|
||||
args: TemplateArgsType,
|
||||
) -> MockObj:
|
||||
var = cg.new_Pvariable(action_id, template_arg)
|
||||
await cg.register_parented(var, config[CONF_ID])
|
||||
return var
|
||||
|
||||
@@ -14,8 +14,6 @@ from esphome.const import (
|
||||
UNIT_PERCENT,
|
||||
UNIT_VOLT,
|
||||
)
|
||||
from esphome.core import ID
|
||||
from esphome.cpp_generator import MockObj, TemplateArgsType
|
||||
from esphome.types import ConfigType
|
||||
|
||||
DEPENDENCIES = ["i2c"]
|
||||
@@ -74,14 +72,9 @@ MAX17043_ACTION_SCHEMA = maybe_simple_id(
|
||||
)
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
"max17043.sleep_mode", SleepAction, MAX17043_ACTION_SCHEMA, synchronous=True
|
||||
automation.register_simple_action(
|
||||
"max17043.sleep_mode",
|
||||
SleepAction,
|
||||
MAX17043_ACTION_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
async def max17043_sleep_mode_to_code(
|
||||
config: ConfigType,
|
||||
action_id: ID,
|
||||
template_arg: cg.TemplateArguments,
|
||||
args: TemplateArgsType,
|
||||
) -> MockObj:
|
||||
paren = await cg.get_variable(config[CONF_ID])
|
||||
return cg.new_Pvariable(action_id, template_arg, paren)
|
||||
|
||||
@@ -144,36 +144,28 @@ TERMINAL_ACTION_SCHEMA = cv.Schema(
|
||||
)
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
"mcp4461.wiper.increase", WiperIncreaseAction, WIPER_ACTION_SCHEMA, synchronous=True
|
||||
automation.register_simple_action(
|
||||
"mcp4461.wiper.increase",
|
||||
WiperIncreaseAction,
|
||||
WIPER_ACTION_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
@automation.register_action(
|
||||
"mcp4461.wiper.decrease", WiperDecreaseAction, WIPER_ACTION_SCHEMA, synchronous=True
|
||||
)
|
||||
async def mcp4461_wiper_step_to_code(
|
||||
config: ConfigType,
|
||||
action_id: ID,
|
||||
template_arg: cg.TemplateArguments,
|
||||
args: TemplateArgsType,
|
||||
) -> MockObj:
|
||||
wiper = await cg.get_variable(config[CONF_ID])
|
||||
return cg.new_Pvariable(action_id, template_arg, wiper)
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
automation.register_simple_action(
|
||||
"mcp4461.wiper.decrease",
|
||||
WiperDecreaseAction,
|
||||
WIPER_ACTION_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
|
||||
|
||||
automation.register_simple_action(
|
||||
"mcp4461.wiper.store_nonvolatile",
|
||||
WiperStoreNonvolatileAction,
|
||||
WIPER_ACTION_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
async def mcp4461_wiper_store_to_code(
|
||||
config: ConfigType,
|
||||
action_id: ID,
|
||||
template_arg: cg.TemplateArguments,
|
||||
args: TemplateArgsType,
|
||||
) -> MockObj:
|
||||
wiper = await cg.get_variable(config[CONF_ID])
|
||||
return cg.new_Pvariable(action_id, template_arg, wiper)
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
|
||||
@@ -122,33 +122,28 @@ NO_ARGS_ACTION_SCHEMA = maybe_simple_id(
|
||||
)
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
automation.register_parented_action(
|
||||
"mhz19.calibrate_zero",
|
||||
MHZ19CalibrateZeroAction,
|
||||
NO_ARGS_ACTION_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
@automation.register_action(
|
||||
|
||||
|
||||
automation.register_parented_action(
|
||||
"mhz19.abc_enable",
|
||||
MHZ19ABCEnableAction,
|
||||
NO_ARGS_ACTION_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
@automation.register_action(
|
||||
|
||||
|
||||
automation.register_parented_action(
|
||||
"mhz19.abc_disable",
|
||||
MHZ19ABCDisableAction,
|
||||
NO_ARGS_ACTION_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
async def mhz19_no_args_action_to_code(
|
||||
config: ConfigType,
|
||||
action_id: ID,
|
||||
template_arg: cg.TemplateArguments,
|
||||
args: TemplateArgsType,
|
||||
) -> MockObj:
|
||||
var = cg.new_Pvariable(action_id, template_arg)
|
||||
await cg.register_parented(var, config[CONF_ID])
|
||||
return var
|
||||
|
||||
|
||||
RANGE_ACTION_SCHEMA = maybe_simple_id(
|
||||
|
||||
@@ -162,21 +162,12 @@ async def remote_temperature_action_to_code(
|
||||
return var
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
automation.register_parented_action(
|
||||
f"{DOMAIN}.clear_remote_temperature",
|
||||
ClearRemoteTemperatureAction,
|
||||
CLEAR_REMOTE_TEMPERATURE_ACTION_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
async def clear_temperature_action_to_code(
|
||||
config: ConfigType,
|
||||
action_id: ID,
|
||||
template_arg: cg.TemplateArguments,
|
||||
args: TemplateArgsType,
|
||||
) -> MockObj:
|
||||
var = cg.new_Pvariable(action_id, template_arg)
|
||||
await cg.register_parented(var, config[CONF_ID])
|
||||
return var
|
||||
|
||||
|
||||
VANE_CONTROL_ACTION_SCHEMA = cv.Schema(
|
||||
|
||||
@@ -4,8 +4,6 @@ import esphome.codegen as cg
|
||||
from esphome.components import i2c, sensor
|
||||
import esphome.config_validation as cv
|
||||
from esphome.const import CONF_GAIN, CONF_ID, ICON_SCALE, STATE_CLASS_MEASUREMENT
|
||||
from esphome.core import ID
|
||||
from esphome.cpp_generator import MockObj, TemplateArgsType
|
||||
from esphome.types import ConfigType
|
||||
|
||||
CODEOWNERS = ["@cujomalainey"]
|
||||
@@ -116,30 +114,25 @@ NAU7802_CALIBRATE_SCHEMA = maybe_simple_id(
|
||||
)
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
automation.register_parented_action(
|
||||
"nau7802.calibrate_internal_offset",
|
||||
NAU7802CalbrateInternalOffsetAction,
|
||||
NAU7802_CALIBRATE_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
@automation.register_action(
|
||||
|
||||
|
||||
automation.register_parented_action(
|
||||
"nau7802.calibrate_external_offset",
|
||||
NAU7802CalbrateExternalOffsetAction,
|
||||
NAU7802_CALIBRATE_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
@automation.register_action(
|
||||
|
||||
|
||||
automation.register_parented_action(
|
||||
"nau7802.calibrate_gain",
|
||||
NAU7802CalbrateGainAction,
|
||||
NAU7802_CALIBRATE_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
async def nau7802_calibrate_to_code(
|
||||
config: ConfigType,
|
||||
action_id: ID,
|
||||
template_arg: cg.TemplateArguments,
|
||||
args: TemplateArgsType,
|
||||
) -> MockObj:
|
||||
var = cg.new_Pvariable(action_id, template_arg)
|
||||
await cg.register_parented(var, config[CONF_ID])
|
||||
return var
|
||||
|
||||
@@ -3,8 +3,6 @@ import esphome.codegen as cg
|
||||
from esphome.components import i2c, time
|
||||
import esphome.config_validation as cv
|
||||
from esphome.const import CONF_ID
|
||||
from esphome.core import ID
|
||||
from esphome.cpp_generator import MockObj, TemplateArgsType
|
||||
from esphome.types import ConfigType
|
||||
|
||||
CODEOWNERS = ["@brogon"]
|
||||
@@ -24,7 +22,7 @@ CONFIG_SCHEMA = time.TIME_SCHEMA.extend(
|
||||
).extend(i2c.i2c_device_schema(0x51))
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
automation.register_parented_action(
|
||||
"pcf85063.write_time",
|
||||
WriteAction,
|
||||
cv.Schema(
|
||||
@@ -34,18 +32,9 @@ CONFIG_SCHEMA = time.TIME_SCHEMA.extend(
|
||||
),
|
||||
synchronous=True,
|
||||
)
|
||||
async def pcf85063_write_time_to_code(
|
||||
config: ConfigType,
|
||||
action_id: ID,
|
||||
template_arg: cg.TemplateArguments,
|
||||
args: TemplateArgsType,
|
||||
) -> MockObj:
|
||||
var = cg.new_Pvariable(action_id, template_arg)
|
||||
await cg.register_parented(var, config[CONF_ID])
|
||||
return var
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
automation.register_parented_action(
|
||||
"pcf85063.read_time",
|
||||
ReadAction,
|
||||
automation.maybe_simple_id(
|
||||
@@ -55,15 +44,6 @@ async def pcf85063_write_time_to_code(
|
||||
),
|
||||
synchronous=True,
|
||||
)
|
||||
async def pcf85063_read_time_to_code(
|
||||
config: ConfigType,
|
||||
action_id: ID,
|
||||
template_arg: cg.TemplateArguments,
|
||||
args: TemplateArgsType,
|
||||
) -> MockObj:
|
||||
var = cg.new_Pvariable(action_id, template_arg)
|
||||
await cg.register_parented(var, config[CONF_ID])
|
||||
return var
|
||||
|
||||
|
||||
async def to_code(config: ConfigType) -> None:
|
||||
|
||||
@@ -3,8 +3,6 @@ import esphome.codegen as cg
|
||||
from esphome.components import i2c, time
|
||||
import esphome.config_validation as cv
|
||||
from esphome.const import CONF_ID
|
||||
from esphome.core import ID
|
||||
from esphome.cpp_generator import MockObj, TemplateArgsType
|
||||
from esphome.types import ConfigType
|
||||
|
||||
CODEOWNERS = ["@KoenBreeman"]
|
||||
@@ -27,7 +25,7 @@ CONFIG_SCHEMA = time.TIME_SCHEMA.extend(
|
||||
).extend(i2c.i2c_device_schema(0x51))
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
automation.register_parented_action(
|
||||
"pcf8563.write_time",
|
||||
WriteAction,
|
||||
automation.maybe_simple_id(
|
||||
@@ -37,18 +35,9 @@ CONFIG_SCHEMA = time.TIME_SCHEMA.extend(
|
||||
),
|
||||
synchronous=True,
|
||||
)
|
||||
async def pcf8563_write_time_to_code(
|
||||
config: ConfigType,
|
||||
action_id: ID,
|
||||
template_arg: cg.TemplateArguments,
|
||||
args: TemplateArgsType,
|
||||
) -> MockObj:
|
||||
var = cg.new_Pvariable(action_id, template_arg)
|
||||
await cg.register_parented(var, config[CONF_ID])
|
||||
return var
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
automation.register_parented_action(
|
||||
"pcf8563.read_time",
|
||||
ReadAction,
|
||||
automation.maybe_simple_id(
|
||||
@@ -58,15 +47,6 @@ async def pcf8563_write_time_to_code(
|
||||
),
|
||||
synchronous=True,
|
||||
)
|
||||
async def pcf8563_read_time_to_code(
|
||||
config: ConfigType,
|
||||
action_id: ID,
|
||||
template_arg: cg.TemplateArguments,
|
||||
args: TemplateArgsType,
|
||||
) -> MockObj:
|
||||
var = cg.new_Pvariable(action_id, template_arg)
|
||||
await cg.register_parented(var, config[CONF_ID])
|
||||
return var
|
||||
|
||||
|
||||
async def to_code(config: ConfigType) -> None:
|
||||
|
||||
@@ -105,26 +105,20 @@ PMWCS3_CALIBRATION_SCHEMA = cv.Schema(
|
||||
)
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
automation.register_simple_action(
|
||||
"pmwcs3.air_calibration",
|
||||
PMWCS3AirCalibrationAction,
|
||||
PMWCS3_CALIBRATION_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
@automation.register_action(
|
||||
|
||||
|
||||
automation.register_simple_action(
|
||||
"pmwcs3.water_calibration",
|
||||
PMWCS3WaterCalibrationAction,
|
||||
PMWCS3_CALIBRATION_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
async def pmwcs3_calibration_to_code(
|
||||
config: ConfigType,
|
||||
action_id: ID,
|
||||
template_arg: cg.TemplateArguments,
|
||||
args: TemplateArgsType,
|
||||
) -> MockObj:
|
||||
parent = await cg.get_variable(config[CONF_ID])
|
||||
return cg.new_Pvariable(action_id, template_arg, parent)
|
||||
|
||||
|
||||
PMWCS3_NEW_I2C_ADDRESS_SCHEMA = cv.maybe_simple_value(
|
||||
|
||||
@@ -3,14 +3,12 @@ import esphome.codegen as cg
|
||||
from esphome.components import nfc
|
||||
import esphome.config_validation as cv
|
||||
from esphome.const import (
|
||||
CONF_ID,
|
||||
CONF_ON_FINISHED_WRITE,
|
||||
CONF_ON_TAG,
|
||||
CONF_ON_TAG_REMOVED,
|
||||
CONF_TRIGGER_ID,
|
||||
)
|
||||
from esphome.core import ID
|
||||
from esphome.cpp_generator import MockObj, TemplateArgsType
|
||||
from esphome.cpp_generator import MockObj
|
||||
from esphome.types import ConfigType
|
||||
|
||||
CODEOWNERS = ["@OttoWinter", "@jesserockz"]
|
||||
@@ -79,7 +77,7 @@ async def setup_pn532(var: MockObj, config: ConfigType) -> None:
|
||||
await automation.build_callback_automations(var, config, _CALLBACK_AUTOMATIONS)
|
||||
|
||||
|
||||
@automation.register_condition(
|
||||
automation.register_parented_condition(
|
||||
"pn532.is_writing",
|
||||
PN532IsWritingCondition,
|
||||
cv.Schema(
|
||||
@@ -88,12 +86,3 @@ async def setup_pn532(var: MockObj, config: ConfigType) -> None:
|
||||
}
|
||||
),
|
||||
)
|
||||
async def pn532_is_writing_to_code(
|
||||
config: ConfigType,
|
||||
condition_id: ID,
|
||||
template_arg: cg.TemplateArguments,
|
||||
args: TemplateArgsType,
|
||||
) -> MockObj:
|
||||
var = cg.new_Pvariable(condition_id, template_arg)
|
||||
await cg.register_parented(var, config[CONF_ID])
|
||||
return var
|
||||
|
||||
@@ -127,54 +127,68 @@ async def pn7150_set_message_to_code(
|
||||
return var
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
automation.register_parented_action(
|
||||
"tag.emulation_off",
|
||||
EmulationOffAction,
|
||||
SIMPLE_ACTION_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
@automation.register_action(
|
||||
"tag.emulation_on", EmulationOnAction, SIMPLE_ACTION_SCHEMA, synchronous=True
|
||||
|
||||
|
||||
automation.register_parented_action(
|
||||
"tag.emulation_on",
|
||||
EmulationOnAction,
|
||||
SIMPLE_ACTION_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
@automation.register_action(
|
||||
"tag.polling_off", PollingOffAction, SIMPLE_ACTION_SCHEMA, synchronous=True
|
||||
|
||||
|
||||
automation.register_parented_action(
|
||||
"tag.polling_off",
|
||||
PollingOffAction,
|
||||
SIMPLE_ACTION_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
@automation.register_action(
|
||||
"tag.polling_on", PollingOnAction, SIMPLE_ACTION_SCHEMA, synchronous=True
|
||||
|
||||
|
||||
automation.register_parented_action(
|
||||
"tag.polling_on",
|
||||
PollingOnAction,
|
||||
SIMPLE_ACTION_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
@automation.register_action(
|
||||
|
||||
|
||||
automation.register_parented_action(
|
||||
"tag.set_clean_mode",
|
||||
SetCleanModeAction,
|
||||
SIMPLE_ACTION_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
@automation.register_action(
|
||||
|
||||
|
||||
automation.register_parented_action(
|
||||
"tag.set_format_mode",
|
||||
SetFormatModeAction,
|
||||
SIMPLE_ACTION_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
@automation.register_action(
|
||||
|
||||
|
||||
automation.register_parented_action(
|
||||
"tag.set_read_mode",
|
||||
SetReadModeAction,
|
||||
SIMPLE_ACTION_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
@automation.register_action(
|
||||
|
||||
|
||||
automation.register_parented_action(
|
||||
"tag.set_write_mode",
|
||||
SetWriteModeAction,
|
||||
SIMPLE_ACTION_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
async def pn7150_simple_action_to_code(
|
||||
config: ConfigType,
|
||||
action_id: ID,
|
||||
template_arg: cg.TemplateArguments,
|
||||
args: TemplateArgsType,
|
||||
) -> MockObj:
|
||||
var = cg.new_Pvariable(action_id, template_arg)
|
||||
await cg.register_parented(var, config[CONF_ID])
|
||||
return var
|
||||
|
||||
|
||||
_CALLBACK_AUTOMATIONS = (
|
||||
@@ -220,7 +234,7 @@ async def setup_pn7150(var: MockObj, config: ConfigType) -> None:
|
||||
await automation.build_callback_automations(var, config, _CALLBACK_AUTOMATIONS)
|
||||
|
||||
|
||||
@automation.register_condition(
|
||||
automation.register_parented_condition(
|
||||
"pn7150.is_writing",
|
||||
PN7150IsWritingCondition,
|
||||
cv.Schema(
|
||||
@@ -229,12 +243,3 @@ async def setup_pn7150(var: MockObj, config: ConfigType) -> None:
|
||||
}
|
||||
),
|
||||
)
|
||||
async def pn7150_is_writing_to_code(
|
||||
config: ConfigType,
|
||||
condition_id: ID,
|
||||
template_arg: cg.TemplateArguments,
|
||||
args: TemplateArgsType,
|
||||
) -> MockObj:
|
||||
var = cg.new_Pvariable(condition_id, template_arg)
|
||||
await cg.register_parented(var, config[CONF_ID])
|
||||
return var
|
||||
|
||||
@@ -131,54 +131,68 @@ async def pn7160_set_message_to_code(
|
||||
return var
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
automation.register_parented_action(
|
||||
"tag.emulation_off",
|
||||
EmulationOffAction,
|
||||
SIMPLE_ACTION_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
@automation.register_action(
|
||||
"tag.emulation_on", EmulationOnAction, SIMPLE_ACTION_SCHEMA, synchronous=True
|
||||
|
||||
|
||||
automation.register_parented_action(
|
||||
"tag.emulation_on",
|
||||
EmulationOnAction,
|
||||
SIMPLE_ACTION_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
@automation.register_action(
|
||||
"tag.polling_off", PollingOffAction, SIMPLE_ACTION_SCHEMA, synchronous=True
|
||||
|
||||
|
||||
automation.register_parented_action(
|
||||
"tag.polling_off",
|
||||
PollingOffAction,
|
||||
SIMPLE_ACTION_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
@automation.register_action(
|
||||
"tag.polling_on", PollingOnAction, SIMPLE_ACTION_SCHEMA, synchronous=True
|
||||
|
||||
|
||||
automation.register_parented_action(
|
||||
"tag.polling_on",
|
||||
PollingOnAction,
|
||||
SIMPLE_ACTION_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
@automation.register_action(
|
||||
|
||||
|
||||
automation.register_parented_action(
|
||||
"tag.set_clean_mode",
|
||||
SetCleanModeAction,
|
||||
SIMPLE_ACTION_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
@automation.register_action(
|
||||
|
||||
|
||||
automation.register_parented_action(
|
||||
"tag.set_format_mode",
|
||||
SetFormatModeAction,
|
||||
SIMPLE_ACTION_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
@automation.register_action(
|
||||
|
||||
|
||||
automation.register_parented_action(
|
||||
"tag.set_read_mode",
|
||||
SetReadModeAction,
|
||||
SIMPLE_ACTION_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
@automation.register_action(
|
||||
|
||||
|
||||
automation.register_parented_action(
|
||||
"tag.set_write_mode",
|
||||
SetWriteModeAction,
|
||||
SIMPLE_ACTION_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
async def pn7160_simple_action_to_code(
|
||||
config: ConfigType,
|
||||
action_id: ID,
|
||||
template_arg: cg.TemplateArguments,
|
||||
args: TemplateArgsType,
|
||||
) -> MockObj:
|
||||
var = cg.new_Pvariable(action_id, template_arg)
|
||||
await cg.register_parented(var, config[CONF_ID])
|
||||
return var
|
||||
|
||||
|
||||
_CALLBACK_AUTOMATIONS = (
|
||||
@@ -232,7 +246,7 @@ async def setup_pn7160(var: MockObj, config: ConfigType) -> None:
|
||||
await automation.build_callback_automations(var, config, _CALLBACK_AUTOMATIONS)
|
||||
|
||||
|
||||
@automation.register_condition(
|
||||
automation.register_parented_condition(
|
||||
"pn7160.is_writing",
|
||||
PN7160IsWritingCondition,
|
||||
cv.Schema(
|
||||
@@ -241,12 +255,3 @@ async def setup_pn7160(var: MockObj, config: ConfigType) -> None:
|
||||
}
|
||||
),
|
||||
)
|
||||
async def pn7160_is_writing_to_code(
|
||||
config: ConfigType,
|
||||
condition_id: ID,
|
||||
template_arg: cg.TemplateArguments,
|
||||
args: TemplateArgsType,
|
||||
) -> MockObj:
|
||||
var = cg.new_Pvariable(condition_id, template_arg)
|
||||
await cg.register_parented(var, config[CONF_ID])
|
||||
return var
|
||||
|
||||
@@ -26,8 +26,6 @@ from esphome.const import (
|
||||
UNIT_WATT,
|
||||
UNIT_WATT_HOURS,
|
||||
)
|
||||
from esphome.core import ID
|
||||
from esphome.cpp_generator import MockObj, TemplateArgsType
|
||||
from esphome.types import ConfigType
|
||||
|
||||
AUTO_LOAD = ["modbus"]
|
||||
@@ -85,7 +83,7 @@ CONFIG_SCHEMA = (
|
||||
)
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
automation.register_simple_action(
|
||||
"pzemac.reset_energy",
|
||||
ResetEnergyAction,
|
||||
maybe_simple_id(
|
||||
@@ -95,14 +93,6 @@ CONFIG_SCHEMA = (
|
||||
),
|
||||
synchronous=True,
|
||||
)
|
||||
async def reset_energy_to_code(
|
||||
config: ConfigType,
|
||||
action_id: ID,
|
||||
template_arg: cg.TemplateArguments,
|
||||
args: TemplateArgsType,
|
||||
) -> MockObj:
|
||||
paren = await cg.get_variable(config[CONF_ID])
|
||||
return cg.new_Pvariable(action_id, template_arg, paren)
|
||||
|
||||
|
||||
def _final_validate(config: ConfigType) -> None:
|
||||
|
||||
@@ -20,8 +20,6 @@ from esphome.const import (
|
||||
UNIT_VOLT,
|
||||
UNIT_WATT,
|
||||
)
|
||||
from esphome.core import ID
|
||||
from esphome.cpp_generator import MockObj, TemplateArgsType
|
||||
from esphome.types import ConfigType
|
||||
|
||||
AUTO_LOAD = ["modbus"]
|
||||
@@ -67,7 +65,7 @@ CONFIG_SCHEMA = (
|
||||
)
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
automation.register_simple_action(
|
||||
"pzemdc.reset_energy",
|
||||
ResetEnergyAction,
|
||||
maybe_simple_id(
|
||||
@@ -77,14 +75,6 @@ CONFIG_SCHEMA = (
|
||||
),
|
||||
synchronous=True,
|
||||
)
|
||||
async def reset_energy_to_code(
|
||||
config: ConfigType,
|
||||
action_id: ID,
|
||||
template_arg: cg.TemplateArguments,
|
||||
args: TemplateArgsType,
|
||||
) -> MockObj:
|
||||
paren = await cg.get_variable(config[CONF_ID])
|
||||
return cg.new_Pvariable(action_id, template_arg, paren)
|
||||
|
||||
|
||||
def _final_validate(config: ConfigType) -> None:
|
||||
|
||||
@@ -3,8 +3,6 @@ import esphome.codegen as cg
|
||||
from esphome.components import i2c, time
|
||||
import esphome.config_validation as cv
|
||||
from esphome.const import CONF_ID
|
||||
from esphome.core import ID
|
||||
from esphome.cpp_generator import MockObj, TemplateArgsType
|
||||
from esphome.types import ConfigType
|
||||
|
||||
CODEOWNERS = ["@beormund"]
|
||||
@@ -22,7 +20,7 @@ CONFIG_SCHEMA = time.TIME_SCHEMA.extend(
|
||||
).extend(i2c.i2c_device_schema(0x32))
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
automation.register_parented_action(
|
||||
"rx8130.write_time",
|
||||
WriteAction,
|
||||
cv.Schema(
|
||||
@@ -32,18 +30,9 @@ CONFIG_SCHEMA = time.TIME_SCHEMA.extend(
|
||||
),
|
||||
synchronous=True,
|
||||
)
|
||||
async def rx8130_write_time_to_code(
|
||||
config: ConfigType,
|
||||
action_id: ID,
|
||||
template_arg: cg.TemplateArguments,
|
||||
args: TemplateArgsType,
|
||||
) -> MockObj:
|
||||
var = cg.new_Pvariable(action_id, template_arg)
|
||||
await cg.register_parented(var, config[CONF_ID])
|
||||
return var
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
automation.register_parented_action(
|
||||
"rx8130.read_time",
|
||||
ReadAction,
|
||||
automation.maybe_simple_id(
|
||||
@@ -53,15 +42,6 @@ async def rx8130_write_time_to_code(
|
||||
),
|
||||
synchronous=True,
|
||||
)
|
||||
async def rx8130_read_time_to_code(
|
||||
config: ConfigType,
|
||||
action_id: ID,
|
||||
template_arg: cg.TemplateArguments,
|
||||
args: TemplateArgsType,
|
||||
) -> MockObj:
|
||||
var = cg.new_Pvariable(action_id, template_arg)
|
||||
await cg.register_parented(var, config[CONF_ID])
|
||||
return var
|
||||
|
||||
|
||||
async def to_code(config: ConfigType) -> None:
|
||||
|
||||
@@ -166,18 +166,9 @@ SCD4X_RESET_ACTION_SCHEMA = maybe_simple_id(
|
||||
)
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
automation.register_parented_action(
|
||||
"scd4x.factory_reset",
|
||||
FactoryResetAction,
|
||||
SCD4X_RESET_ACTION_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
async def scd4x_reset_to_code(
|
||||
config: ConfigType,
|
||||
action_id: ID,
|
||||
template_arg: cg.TemplateArguments,
|
||||
args: TemplateArgsType,
|
||||
) -> MockObj:
|
||||
var = cg.new_Pvariable(action_id, template_arg)
|
||||
await cg.register_parented(var, config[CONF_ID])
|
||||
return var
|
||||
|
||||
@@ -43,8 +43,6 @@ from esphome.const import (
|
||||
UNIT_MICROGRAMS_PER_CUBIC_METER,
|
||||
UNIT_PERCENT,
|
||||
)
|
||||
from esphome.core import ID
|
||||
from esphome.cpp_generator import MockObj, TemplateArgsType
|
||||
from esphome.types import ConfigType
|
||||
|
||||
CODEOWNERS = ["@martgras"]
|
||||
@@ -282,17 +280,9 @@ SEN5X_ACTION_SCHEMA = maybe_simple_id(
|
||||
)
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
automation.register_simple_action(
|
||||
"sen5x.start_fan_autoclean",
|
||||
StartFanAction,
|
||||
SEN5X_ACTION_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
async def sen54_fan_to_code(
|
||||
config: ConfigType,
|
||||
action_id: ID,
|
||||
template_arg: cg.TemplateArguments,
|
||||
args: TemplateArgsType,
|
||||
) -> MockObj:
|
||||
paren = await cg.get_variable(config[CONF_ID])
|
||||
return cg.new_Pvariable(action_id, template_arg, paren)
|
||||
|
||||
@@ -11,8 +11,6 @@ from esphome.const import (
|
||||
STATE_CLASS_MEASUREMENT,
|
||||
UNIT_PARTS_PER_MILLION,
|
||||
)
|
||||
from esphome.core import ID
|
||||
from esphome.cpp_generator import MockObj, TemplateArgsType
|
||||
from esphome.types import ConfigType
|
||||
|
||||
DEPENDENCIES = ["uart"]
|
||||
@@ -82,41 +80,41 @@ CALIBRATION_ACTION_SCHEMA = maybe_simple_id(
|
||||
)
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
automation.register_simple_action(
|
||||
"senseair.background_calibration",
|
||||
SenseAirBackgroundCalibrationAction,
|
||||
CALIBRATION_ACTION_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
@automation.register_action(
|
||||
|
||||
|
||||
automation.register_simple_action(
|
||||
"senseair.background_calibration_result",
|
||||
SenseAirBackgroundCalibrationResultAction,
|
||||
CALIBRATION_ACTION_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
@automation.register_action(
|
||||
|
||||
|
||||
automation.register_simple_action(
|
||||
"senseair.abc_enable",
|
||||
SenseAirABCEnableAction,
|
||||
CALIBRATION_ACTION_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
@automation.register_action(
|
||||
|
||||
|
||||
automation.register_simple_action(
|
||||
"senseair.abc_disable",
|
||||
SenseAirABCDisableAction,
|
||||
CALIBRATION_ACTION_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
@automation.register_action(
|
||||
|
||||
|
||||
automation.register_simple_action(
|
||||
"senseair.abc_get_period",
|
||||
SenseAirABCGetPeriodAction,
|
||||
CALIBRATION_ACTION_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
async def senseair_action_to_code(
|
||||
config: ConfigType,
|
||||
action_id: ID,
|
||||
template_arg: cg.TemplateArguments,
|
||||
args: TemplateArgsType,
|
||||
) -> MockObj:
|
||||
paren = await cg.get_variable(config[CONF_ID])
|
||||
return cg.new_Pvariable(action_id, template_arg, paren)
|
||||
|
||||
@@ -125,15 +125,12 @@ async def sim800l_dial_to_code(config, action_id, template_arg, args):
|
||||
return var
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
automation.register_simple_action(
|
||||
"sim800l.connect",
|
||||
Sim800LConnectAction,
|
||||
cv.Schema({cv.GenerateID(): cv.use_id(Sim800LComponent)}),
|
||||
synchronous=True,
|
||||
)
|
||||
async def sim800l_connect_to_code(config, action_id, template_arg, args):
|
||||
paren = await cg.get_variable(config[CONF_ID])
|
||||
return cg.new_Pvariable(action_id, template_arg, paren)
|
||||
|
||||
|
||||
SIM800L_SEND_USSD_SCHEMA = cv.Schema(
|
||||
@@ -158,12 +155,9 @@ async def sim800l_send_ussd_to_code(config, action_id, template_arg, args):
|
||||
return var
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
automation.register_simple_action(
|
||||
"sim800l.disconnect",
|
||||
Sim800LDisconnectAction,
|
||||
cv.Schema({cv.GenerateID(): cv.use_id(Sim800LComponent)}),
|
||||
synchronous=True,
|
||||
)
|
||||
async def sim800l_disconnect_to_code(config, action_id, template_arg, args):
|
||||
paren = await cg.get_variable(config[CONF_ID])
|
||||
return cg.new_Pvariable(action_id, template_arg, paren)
|
||||
|
||||
@@ -11,8 +11,6 @@ from esphome.const import (
|
||||
STATE_CLASS_MEASUREMENT,
|
||||
UNIT_DECIBEL,
|
||||
)
|
||||
from esphome.core import ID
|
||||
from esphome.cpp_generator import MockObj, TemplateArgsType
|
||||
from esphome.types import ConfigType
|
||||
|
||||
AUTO_LOAD = ["audio"]
|
||||
@@ -92,18 +90,17 @@ SOUND_LEVEL_ACTION_SCHEMA = automation.maybe_simple_id(
|
||||
)
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
"sound_level.start", StartAction, SOUND_LEVEL_ACTION_SCHEMA, synchronous=True
|
||||
automation.register_parented_action(
|
||||
"sound_level.start",
|
||||
StartAction,
|
||||
SOUND_LEVEL_ACTION_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
@automation.register_action(
|
||||
"sound_level.stop", StopAction, SOUND_LEVEL_ACTION_SCHEMA, synchronous=True
|
||||
|
||||
|
||||
automation.register_parented_action(
|
||||
"sound_level.stop",
|
||||
StopAction,
|
||||
SOUND_LEVEL_ACTION_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
async def sound_level_action_to_code(
|
||||
config: ConfigType,
|
||||
action_id: ID,
|
||||
template_arg: cg.TemplateArguments,
|
||||
args: TemplateArgsType,
|
||||
) -> MockObj:
|
||||
var = cg.new_Pvariable(action_id, template_arg)
|
||||
await cg.register_parented(var, config[CONF_ID])
|
||||
return var
|
||||
|
||||
@@ -446,26 +446,20 @@ automation.register_apply_action(
|
||||
)
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
automation.register_simple_action(
|
||||
"sprinkler.start_from_queue",
|
||||
StartFromQueueAction,
|
||||
SPRINKLER_ACTION_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
async def sprinkler_start_from_queue_to_code(config, action_id, template_arg, args):
|
||||
paren = await cg.get_variable(config[CONF_ID])
|
||||
return cg.new_Pvariable(action_id, template_arg, paren)
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
automation.register_simple_action(
|
||||
"sprinkler.start_full_cycle",
|
||||
StartFullCycleAction,
|
||||
SPRINKLER_ACTION_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
async def sprinkler_start_full_cycle_to_code(config, action_id, template_arg, args):
|
||||
paren = await cg.get_variable(config[CONF_ID])
|
||||
return cg.new_Pvariable(action_id, template_arg, paren)
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
@@ -485,45 +479,60 @@ async def sprinkler_start_single_valve_to_code(config, action_id, template_arg,
|
||||
return var
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
automation.register_simple_action(
|
||||
"sprinkler.clear_queued_valves",
|
||||
ClearQueuedValvesAction,
|
||||
SPRINKLER_ACTION_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
@automation.register_action(
|
||||
|
||||
|
||||
automation.register_simple_action(
|
||||
"sprinkler.next_valve",
|
||||
NextValveAction,
|
||||
SPRINKLER_ACTION_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
@automation.register_action(
|
||||
|
||||
|
||||
automation.register_simple_action(
|
||||
"sprinkler.previous_valve",
|
||||
PreviousValveAction,
|
||||
SPRINKLER_ACTION_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
@automation.register_action(
|
||||
"sprinkler.pause", PauseAction, SPRINKLER_ACTION_SCHEMA, synchronous=True
|
||||
|
||||
|
||||
automation.register_simple_action(
|
||||
"sprinkler.pause",
|
||||
PauseAction,
|
||||
SPRINKLER_ACTION_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
@automation.register_action(
|
||||
"sprinkler.resume", ResumeAction, SPRINKLER_ACTION_SCHEMA, synchronous=True
|
||||
|
||||
|
||||
automation.register_simple_action(
|
||||
"sprinkler.resume",
|
||||
ResumeAction,
|
||||
SPRINKLER_ACTION_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
@automation.register_action(
|
||||
|
||||
|
||||
automation.register_simple_action(
|
||||
"sprinkler.resume_or_start_full_cycle",
|
||||
ResumeOrStartAction,
|
||||
SPRINKLER_ACTION_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
@automation.register_action(
|
||||
|
||||
|
||||
automation.register_simple_action(
|
||||
"sprinkler.shutdown",
|
||||
ShutdownAction,
|
||||
SPRINKLER_ACTION_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
async def sprinkler_simple_action_to_code(config, action_id, template_arg, args):
|
||||
paren = await cg.get_variable(config[CONF_ID])
|
||||
return cg.new_Pvariable(action_id, template_arg, paren)
|
||||
|
||||
|
||||
async def to_code(config):
|
||||
|
||||
@@ -26,8 +26,6 @@ from esphome.const import (
|
||||
UNIT_MICROGRAMS_PER_CUBIC_METER,
|
||||
UNIT_MICROMETER,
|
||||
)
|
||||
from esphome.core import ID
|
||||
from esphome.cpp_generator import MockObj, TemplateArgsType
|
||||
from esphome.types import ConfigType
|
||||
|
||||
CODEOWNERS = ["@martgras"]
|
||||
@@ -182,30 +180,25 @@ SPS30_ACTION_SCHEMA = maybe_simple_id(
|
||||
)
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
automation.register_parented_action(
|
||||
"sps30.start_fan_autoclean",
|
||||
StartFanAction,
|
||||
SPS30_ACTION_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
@automation.register_action(
|
||||
|
||||
|
||||
automation.register_parented_action(
|
||||
"sps30.start_measurement",
|
||||
StartMeasurementAction,
|
||||
SPS30_ACTION_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
@automation.register_action(
|
||||
|
||||
|
||||
automation.register_parented_action(
|
||||
"sps30.stop_measurement",
|
||||
StopMeasurementAction,
|
||||
SPS30_ACTION_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
async def sps30_action_to_code(
|
||||
config: ConfigType,
|
||||
action_id: ID,
|
||||
template_arg: cg.TemplateArguments,
|
||||
args: TemplateArgsType,
|
||||
) -> MockObj:
|
||||
var = cg.new_Pvariable(action_id, template_arg)
|
||||
await cg.register_parented(var, config[CONF_ID])
|
||||
return var
|
||||
|
||||
@@ -302,39 +302,36 @@ NO_ARGS_ACTION_SCHEMA = automation.maybe_simple_id(
|
||||
)
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
automation.register_parented_action(
|
||||
"sx126x.run_image_cal",
|
||||
RunImageCalAction,
|
||||
NO_ARGS_ACTION_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
@automation.register_action(
|
||||
|
||||
|
||||
automation.register_parented_action(
|
||||
"sx126x.set_mode_tx",
|
||||
SetModeTxAction,
|
||||
NO_ARGS_ACTION_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
@automation.register_action(
|
||||
|
||||
|
||||
automation.register_parented_action(
|
||||
"sx126x.set_mode_rx",
|
||||
SetModeRxAction,
|
||||
NO_ARGS_ACTION_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
@automation.register_action(
|
||||
|
||||
|
||||
automation.register_parented_action(
|
||||
"sx126x.set_mode_standby",
|
||||
SetModeStandbyAction,
|
||||
NO_ARGS_ACTION_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
async def no_args_action_to_code(
|
||||
config: ConfigType,
|
||||
action_id: ID,
|
||||
template_arg: cg.TemplateArguments,
|
||||
args: TemplateArgsType,
|
||||
) -> MockObj:
|
||||
var = cg.new_Pvariable(action_id, template_arg)
|
||||
await cg.register_parented(var, config[CONF_ID])
|
||||
return var
|
||||
|
||||
|
||||
SET_MODE_SLEEP_ACTION_SCHEMA = automation.maybe_simple_id(
|
||||
|
||||
@@ -286,45 +286,44 @@ NO_ARGS_ACTION_SCHEMA = automation.maybe_simple_id(
|
||||
)
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
automation.register_parented_action(
|
||||
"sx127x.run_image_cal",
|
||||
RunImageCalAction,
|
||||
NO_ARGS_ACTION_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
@automation.register_action(
|
||||
|
||||
|
||||
automation.register_parented_action(
|
||||
"sx127x.set_mode_tx",
|
||||
SetModeTxAction,
|
||||
NO_ARGS_ACTION_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
@automation.register_action(
|
||||
|
||||
|
||||
automation.register_parented_action(
|
||||
"sx127x.set_mode_rx",
|
||||
SetModeRxAction,
|
||||
NO_ARGS_ACTION_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
@automation.register_action(
|
||||
|
||||
|
||||
automation.register_parented_action(
|
||||
"sx127x.set_mode_sleep",
|
||||
SetModeSleepAction,
|
||||
NO_ARGS_ACTION_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
@automation.register_action(
|
||||
|
||||
|
||||
automation.register_parented_action(
|
||||
"sx127x.set_mode_standby",
|
||||
SetModeStandbyAction,
|
||||
NO_ARGS_ACTION_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
async def no_args_action_to_code(
|
||||
config: ConfigType,
|
||||
action_id: ID,
|
||||
template_arg: cg.TemplateArguments,
|
||||
args: TemplateArgsType,
|
||||
) -> MockObj:
|
||||
var = cg.new_Pvariable(action_id, template_arg)
|
||||
await cg.register_parented(var, config[CONF_ID])
|
||||
return var
|
||||
|
||||
|
||||
SEND_PACKET_ACTION_SCHEMA = cv.maybe_simple_value(
|
||||
|
||||
@@ -12,8 +12,6 @@ from esphome.components.esp32 import (
|
||||
)
|
||||
import esphome.config_validation as cv
|
||||
from esphome.const import CONF_HARDWARE_UART, CONF_ID
|
||||
from esphome.core import ID
|
||||
from esphome.cpp_generator import MockObj, TemplateArgsType
|
||||
from esphome.types import ConfigType
|
||||
|
||||
CODEOWNERS = ["@kbx81"]
|
||||
@@ -136,16 +134,8 @@ async def to_code(config: ConfigType) -> None:
|
||||
add_idf_sdkconfig_option("CONFIG_TINYUSB_DESC_BCD_DEVICE", 0x0100)
|
||||
|
||||
|
||||
@automation.register_condition(
|
||||
automation.register_simple_condition(
|
||||
"tinyusb.is_mounted",
|
||||
IsMountedCondition,
|
||||
cv.Schema({cv.GenerateID(): cv.use_id(TinyUSB)}),
|
||||
)
|
||||
async def tinyusb_is_mounted_to_code(
|
||||
config: ConfigType,
|
||||
condition_id: ID,
|
||||
template_arg: cg.TemplateArguments,
|
||||
args: TemplateArgsType,
|
||||
) -> MockObj:
|
||||
paren = await cg.get_variable(config[CONF_ID])
|
||||
return cg.new_Pvariable(condition_id, template_arg, paren)
|
||||
|
||||
@@ -141,32 +141,17 @@ async def tm1651_set_level_percent_to_code(
|
||||
return var
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
automation.register_parented_action(
|
||||
"tm1651.turn_off",
|
||||
TurnOffAction,
|
||||
BINARY_OUTPUT_ACTION_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
async def output_turn_off_to_code(
|
||||
config: ConfigType,
|
||||
action_id: ID,
|
||||
template_arg: cg.TemplateArguments,
|
||||
args: TemplateArgsType,
|
||||
) -> MockObj:
|
||||
var = cg.new_Pvariable(action_id, template_arg)
|
||||
await cg.register_parented(var, config[CONF_ID])
|
||||
return var
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
"tm1651.turn_on", TurnOnAction, BINARY_OUTPUT_ACTION_SCHEMA, synchronous=True
|
||||
automation.register_parented_action(
|
||||
"tm1651.turn_on",
|
||||
TurnOnAction,
|
||||
BINARY_OUTPUT_ACTION_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
async def output_turn_on_to_code(
|
||||
config: ConfigType,
|
||||
action_id: ID,
|
||||
template_arg: cg.TemplateArguments,
|
||||
args: TemplateArgsType,
|
||||
) -> MockObj:
|
||||
var = cg.new_Pvariable(action_id, template_arg)
|
||||
await cg.register_parented(var, config[CONF_ID])
|
||||
return var
|
||||
|
||||
@@ -124,17 +124,9 @@ UFIRE_EC_RESET_SCHEMA = cv.Schema(
|
||||
)
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
automation.register_simple_action(
|
||||
"ufire_ec.reset",
|
||||
UFireECResetAction,
|
||||
UFIRE_EC_RESET_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
async def ufire_ec_reset_to_code(
|
||||
config: ConfigType,
|
||||
action_id: ID,
|
||||
template_arg: cg.TemplateArguments,
|
||||
args: TemplateArgsType,
|
||||
) -> MockObj:
|
||||
paren = await cg.get_variable(config[CONF_ID])
|
||||
return cg.new_Pvariable(action_id, template_arg, paren)
|
||||
|
||||
@@ -131,17 +131,9 @@ async def ufire_ise_calibrate_probe_high_to_code(
|
||||
UFIRE_ISE_RESET_SCHEMA = cv.Schema({cv.GenerateID(): cv.use_id(UFireISEComponent)})
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
automation.register_simple_action(
|
||||
"ufire_ise.reset",
|
||||
UFireISEResetAction,
|
||||
UFIRE_ISE_RESET_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
async def ufire_ise_reset_to_code(
|
||||
config: ConfigType,
|
||||
action_id: ID,
|
||||
template_arg: cg.TemplateArguments,
|
||||
args: TemplateArgsType,
|
||||
) -> MockObj:
|
||||
paren = await cg.get_variable(config[CONF_ID])
|
||||
return cg.new_Pvariable(action_id, template_arg, paren)
|
||||
|
||||
@@ -14,14 +14,14 @@ from esphome.const import (
|
||||
DEVICE_CLASS_FIRMWARE,
|
||||
ENTITY_CATEGORY_CONFIG,
|
||||
)
|
||||
from esphome.core import CORE, ID, CoroPriority, coroutine_with_priority
|
||||
from esphome.core import CORE, CoroPriority, coroutine_with_priority
|
||||
from esphome.core.entity_helpers import (
|
||||
entity_duplicate_validator,
|
||||
queue_entity_register,
|
||||
setup_device_class,
|
||||
setup_entity,
|
||||
)
|
||||
from esphome.cpp_generator import MockObj, MockObjClass, TemplateArgsType
|
||||
from esphome.cpp_generator import MockObj, MockObjClass
|
||||
from esphome.types import ConfigType
|
||||
|
||||
CODEOWNERS = ["@jesserockz"]
|
||||
@@ -144,7 +144,7 @@ automation.register_apply_action(
|
||||
)
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
automation.register_parented_action(
|
||||
"update.check",
|
||||
CheckAction,
|
||||
automation.maybe_simple_id(
|
||||
@@ -154,18 +154,9 @@ automation.register_apply_action(
|
||||
),
|
||||
synchronous=True,
|
||||
)
|
||||
async def update_check_action_to_code(
|
||||
config: ConfigType,
|
||||
action_id: ID,
|
||||
template_arg: cg.TemplateArguments,
|
||||
args: TemplateArgsType,
|
||||
) -> MockObj:
|
||||
var = cg.new_Pvariable(action_id, template_arg)
|
||||
await cg.register_parented(var, config[CONF_ID])
|
||||
return var
|
||||
|
||||
|
||||
@automation.register_condition(
|
||||
automation.register_parented_condition(
|
||||
"update.is_available",
|
||||
IsAvailableCondition,
|
||||
automation.maybe_simple_id(
|
||||
@@ -174,12 +165,3 @@ async def update_check_action_to_code(
|
||||
}
|
||||
),
|
||||
)
|
||||
async def update_is_available_condition_to_code(
|
||||
config: ConfigType,
|
||||
condition_id: ID,
|
||||
template_arg: cg.TemplateArguments,
|
||||
args: TemplateArgsType,
|
||||
) -> MockObj:
|
||||
var = cg.new_Pvariable(condition_id, template_arg)
|
||||
await cg.register_parented(var, config[CONF_ID])
|
||||
return var
|
||||
|
||||
@@ -182,36 +182,36 @@ VALVE_ACTION_SCHEMA = maybe_simple_id(
|
||||
)
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
"valve.open", OpenAction, VALVE_ACTION_SCHEMA, synchronous=True
|
||||
automation.register_simple_action(
|
||||
"valve.open",
|
||||
OpenAction,
|
||||
VALVE_ACTION_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
async def valve_open_to_code(config, action_id, template_arg, args):
|
||||
paren = await cg.get_variable(config[CONF_ID])
|
||||
return cg.new_Pvariable(action_id, template_arg, paren)
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
"valve.close", CloseAction, VALVE_ACTION_SCHEMA, synchronous=True
|
||||
automation.register_simple_action(
|
||||
"valve.close",
|
||||
CloseAction,
|
||||
VALVE_ACTION_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
async def valve_close_to_code(config, action_id, template_arg, args):
|
||||
paren = await cg.get_variable(config[CONF_ID])
|
||||
return cg.new_Pvariable(action_id, template_arg, paren)
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
"valve.stop", StopAction, VALVE_ACTION_SCHEMA, synchronous=True
|
||||
automation.register_simple_action(
|
||||
"valve.stop",
|
||||
StopAction,
|
||||
VALVE_ACTION_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
async def valve_stop_to_code(config, action_id, template_arg, args):
|
||||
paren = await cg.get_variable(config[CONF_ID])
|
||||
return cg.new_Pvariable(action_id, template_arg, paren)
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
"valve.toggle", ToggleAction, VALVE_ACTION_SCHEMA, synchronous=True
|
||||
automation.register_simple_action(
|
||||
"valve.toggle",
|
||||
ToggleAction,
|
||||
VALVE_ACTION_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
async def valve_toggle_to_code(config, action_id, template_arg, args):
|
||||
paren = await cg.get_variable(config[CONF_ID])
|
||||
return cg.new_Pvariable(action_id, template_arg, paren)
|
||||
|
||||
|
||||
VALVE_CONTROL_ACTION_SCHEMA = cv.Schema(
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
from esphome import automation
|
||||
from esphome.automation import register_condition
|
||||
import esphome.codegen as cg
|
||||
from esphome.components import media_player, micro_wake_word, microphone, speaker
|
||||
import esphome.config_validation as cv
|
||||
@@ -14,8 +13,6 @@ from esphome.const import (
|
||||
CONF_ON_START,
|
||||
CONF_SPEAKER,
|
||||
)
|
||||
from esphome.core import ID
|
||||
from esphome.cpp_generator import MockObj, TemplateArgsType
|
||||
from esphome.types import ConfigType
|
||||
|
||||
AUTO_LOAD = ["audio", "ring_buffer", "socket"]
|
||||
@@ -424,29 +421,15 @@ automation.register_apply_action(
|
||||
)
|
||||
|
||||
|
||||
@register_condition(
|
||||
"voice_assistant.is_running", IsRunningCondition, VOICE_ASSISTANT_ACTION_SCHEMA
|
||||
automation.register_parented_condition(
|
||||
"voice_assistant.is_running",
|
||||
IsRunningCondition,
|
||||
VOICE_ASSISTANT_ACTION_SCHEMA,
|
||||
)
|
||||
async def voice_assistant_is_running_to_code(
|
||||
config: ConfigType,
|
||||
condition_id: ID,
|
||||
template_arg: cg.TemplateArguments,
|
||||
args: TemplateArgsType,
|
||||
) -> MockObj:
|
||||
var = cg.new_Pvariable(condition_id, template_arg)
|
||||
await cg.register_parented(var, config[CONF_ID])
|
||||
return var
|
||||
|
||||
|
||||
@register_condition(
|
||||
"voice_assistant.connected", ConnectedCondition, VOICE_ASSISTANT_ACTION_SCHEMA
|
||||
automation.register_parented_condition(
|
||||
"voice_assistant.connected",
|
||||
ConnectedCondition,
|
||||
VOICE_ASSISTANT_ACTION_SCHEMA,
|
||||
)
|
||||
async def voice_assistant_connected_to_code(
|
||||
config: ConfigType,
|
||||
condition_id: ID,
|
||||
template_arg: cg.TemplateArguments,
|
||||
args: TemplateArgsType,
|
||||
) -> MockObj:
|
||||
var = cg.new_Pvariable(condition_id, template_arg)
|
||||
await cg.register_parented(var, config[CONF_ID])
|
||||
return var
|
||||
|
||||
@@ -67,14 +67,13 @@ from esphome.const import (
|
||||
)
|
||||
from esphome.core import (
|
||||
CORE,
|
||||
ID,
|
||||
CoroPriority,
|
||||
EsphomeError,
|
||||
HexInt,
|
||||
coroutine_with_priority,
|
||||
)
|
||||
import esphome.final_validate as fv
|
||||
from esphome.types import ConfigType, TemplateArgsType
|
||||
from esphome.types import ConfigType
|
||||
|
||||
from . import wpa2_eap
|
||||
|
||||
@@ -830,45 +829,49 @@ async def to_code(config):
|
||||
CORE.add_job(final_step)
|
||||
|
||||
|
||||
@automation.register_condition("wifi.connected", WiFiConnectedCondition, cv.Schema({}))
|
||||
async def wifi_connected_to_code(config, condition_id, template_arg, args):
|
||||
return cg.new_Pvariable(condition_id, template_arg)
|
||||
|
||||
|
||||
@automation.register_condition("wifi.enabled", WiFiEnabledCondition, cv.Schema({}))
|
||||
async def wifi_enabled_to_code(config, condition_id, template_arg, args):
|
||||
return cg.new_Pvariable(condition_id, template_arg)
|
||||
|
||||
|
||||
@automation.register_condition("wifi.ap_active", WiFiAPActiveCondition, cv.Schema({}))
|
||||
async def wifi_ap_active_to_code(config, condition_id, template_arg, args):
|
||||
return cg.new_Pvariable(condition_id, template_arg)
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
"wifi.enable", WiFiEnableAction, cv.Schema({}), synchronous=True
|
||||
automation.register_bare_condition(
|
||||
"wifi.connected",
|
||||
WiFiConnectedCondition,
|
||||
cv.Schema({}),
|
||||
)
|
||||
async def wifi_enable_to_code(config, action_id, template_arg, args):
|
||||
return cg.new_Pvariable(action_id, template_arg)
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
"wifi.disable", WiFiDisableAction, cv.Schema({}), synchronous=True
|
||||
automation.register_bare_condition(
|
||||
"wifi.enabled",
|
||||
WiFiEnabledCondition,
|
||||
cv.Schema({}),
|
||||
)
|
||||
async def wifi_disable_to_code(config, action_id, template_arg, args):
|
||||
return cg.new_Pvariable(action_id, template_arg)
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
"wifi.roam", WiFiRoamAction, cv.Schema({}), synchronous=True
|
||||
automation.register_bare_condition(
|
||||
"wifi.ap_active",
|
||||
WiFiAPActiveCondition,
|
||||
cv.Schema({}),
|
||||
)
|
||||
|
||||
|
||||
automation.register_bare_action(
|
||||
"wifi.enable",
|
||||
WiFiEnableAction,
|
||||
cv.Schema({}),
|
||||
synchronous=True,
|
||||
)
|
||||
|
||||
|
||||
automation.register_bare_action(
|
||||
"wifi.disable",
|
||||
WiFiDisableAction,
|
||||
cv.Schema({}),
|
||||
synchronous=True,
|
||||
)
|
||||
|
||||
|
||||
automation.register_bare_action(
|
||||
"wifi.roam",
|
||||
WiFiRoamAction,
|
||||
cv.Schema({}),
|
||||
synchronous=True,
|
||||
)
|
||||
async def wifi_roam_to_code(
|
||||
config: ConfigType,
|
||||
action_id: ID,
|
||||
template_arg: cg.TemplateArguments,
|
||||
args: TemplateArgsType,
|
||||
) -> cg.MockObj:
|
||||
return cg.new_Pvariable(action_id, template_arg)
|
||||
|
||||
|
||||
KEEP_SCAN_RESULTS_KEY = "wifi_keep_scan_results"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import logging
|
||||
from typing import Any
|
||||
|
||||
from esphome import automation, core
|
||||
from esphome import automation
|
||||
import esphome.codegen as cg
|
||||
from esphome.components.esp32 import only_on_variant
|
||||
from esphome.components.esp32.const import (
|
||||
@@ -298,18 +298,9 @@ FactoryResetAction = zigbee_ns.class_(
|
||||
)
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
automation.register_parented_action(
|
||||
"zigbee.factory_reset",
|
||||
FactoryResetAction,
|
||||
ZIGBEE_ACTION_SCHEMA,
|
||||
synchronous=True,
|
||||
)
|
||||
async def reset_zigbee_to_code(
|
||||
config: ConfigType,
|
||||
action_id: core.ID,
|
||||
template_arg: cg.TemplateArguments,
|
||||
args: list[tuple],
|
||||
) -> cg.Pvariable:
|
||||
var = cg.new_Pvariable(action_id, template_arg)
|
||||
await cg.register_parented(var, config[CONF_ID])
|
||||
return var
|
||||
|
||||
Reference in New Issue
Block a user