mirror of
https://github.com/esphome/esphome.git
synced 2026-10-05 10:31:29 +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",
|
"alarm_control_panel.pending",
|
||||||
PendingAction,
|
PendingAction,
|
||||||
ALARM_CONTROL_PANEL_ACTION_SCHEMA,
|
ALARM_CONTROL_PANEL_ACTION_SCHEMA,
|
||||||
synchronous=True,
|
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",
|
"alarm_control_panel.triggered",
|
||||||
TriggeredAction,
|
TriggeredAction,
|
||||||
ALARM_CONTROL_PANEL_ACTION_SCHEMA,
|
ALARM_CONTROL_PANEL_ACTION_SCHEMA,
|
||||||
synchronous=True,
|
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",
|
"alarm_control_panel.chime",
|
||||||
ChimeAction,
|
ChimeAction,
|
||||||
ALARM_CONTROL_PANEL_ACTION_SCHEMA,
|
ALARM_CONTROL_PANEL_ACTION_SCHEMA,
|
||||||
synchronous=True,
|
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",
|
"alarm_control_panel.ready",
|
||||||
ReadyAction,
|
ReadyAction,
|
||||||
ALARM_CONTROL_PANEL_ACTION_SCHEMA,
|
ALARM_CONTROL_PANEL_ACTION_SCHEMA,
|
||||||
synchronous=True,
|
synchronous=True,
|
||||||
)
|
)
|
||||||
@automation.register_condition(
|
|
||||||
|
|
||||||
|
automation.register_simple_condition(
|
||||||
"alarm_control_panel.ready",
|
"alarm_control_panel.ready",
|
||||||
AlarmControlPanelCondition,
|
AlarmControlPanelCondition,
|
||||||
ALARM_CONTROL_PANEL_CONDITION_SCHEMA,
|
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",
|
"alarm_control_panel.is_armed",
|
||||||
AlarmControlPanelCondition,
|
AlarmControlPanelCondition,
|
||||||
ALARM_CONTROL_PANEL_CONDITION_SCHEMA,
|
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)
|
@coroutine_with_priority(CoroPriority.CORE)
|
||||||
|
|||||||
@@ -655,7 +655,7 @@ async def to_code(config):
|
|||||||
cg.add_global(binary_sensor_ns.using)
|
cg.add_global(binary_sensor_ns.using)
|
||||||
|
|
||||||
|
|
||||||
@automation.register_action(
|
automation.register_simple_action(
|
||||||
"binary_sensor.invalidate_state",
|
"binary_sensor.invalidate_state",
|
||||||
BinarySensorInvalidateAction,
|
BinarySensorInvalidateAction,
|
||||||
cv.maybe_simple_value(
|
cv.maybe_simple_value(
|
||||||
@@ -666,9 +666,6 @@ async def to_code(config):
|
|||||||
),
|
),
|
||||||
synchronous=True,
|
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
|
# automation.cpp only implements the click/double_click/multi_click triggers
|
||||||
|
|||||||
@@ -32,8 +32,6 @@ from esphome.const import (
|
|||||||
UNIT_VOLT,
|
UNIT_VOLT,
|
||||||
UNIT_WATT,
|
UNIT_WATT,
|
||||||
)
|
)
|
||||||
from esphome.core import ID
|
|
||||||
from esphome.cpp_generator import MockObj, TemplateArgsType
|
|
||||||
from esphome.types import ConfigType
|
from esphome.types import ConfigType
|
||||||
|
|
||||||
# Import ICONS not included in esphome's const.py, from the local components const.py
|
# 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",
|
"bl0906.reset_energy",
|
||||||
ResetEnergyAction,
|
ResetEnergyAction,
|
||||||
maybe_simple_id(
|
maybe_simple_id(
|
||||||
@@ -148,15 +146,6 @@ FINAL_VALIDATE_SCHEMA = uart.final_validate_device_schema(
|
|||||||
),
|
),
|
||||||
synchronous=True,
|
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:
|
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",
|
"ble_client.disconnect",
|
||||||
BLEDisconnectAction,
|
BLEDisconnectAction,
|
||||||
BLE_CONNECT_ACTION_SCHEMA,
|
BLE_CONNECT_ACTION_SCHEMA,
|
||||||
synchronous=False,
|
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",
|
"ble_client.connect",
|
||||||
BLEConnectAction,
|
BLEConnectAction,
|
||||||
BLE_CONNECT_ACTION_SCHEMA,
|
BLE_CONNECT_ACTION_SCHEMA,
|
||||||
synchronous=False,
|
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(
|
@automation.register_action(
|
||||||
@@ -328,15 +322,12 @@ async def passkey_reply_to_code(config, action_id, template_arg, args):
|
|||||||
return var
|
return var
|
||||||
|
|
||||||
|
|
||||||
@automation.register_action(
|
automation.register_simple_action(
|
||||||
"ble_client.remove_bond",
|
"ble_client.remove_bond",
|
||||||
BLERemoveBondAction,
|
BLERemoveBondAction,
|
||||||
BLE_REMOVE_BOND_ACTION_SCHEMA,
|
BLE_REMOVE_BOND_ACTION_SCHEMA,
|
||||||
synchronous=True,
|
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):
|
async def to_code(config):
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ CONFIG_SCHEMA = (
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@automation.register_action(
|
automation.register_parented_action(
|
||||||
"bm8563.write_time",
|
"bm8563.write_time",
|
||||||
WriteAction,
|
WriteAction,
|
||||||
automation.maybe_simple_id(
|
automation.maybe_simple_id(
|
||||||
@@ -38,15 +38,6 @@ CONFIG_SCHEMA = (
|
|||||||
),
|
),
|
||||||
synchronous=True,
|
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(
|
@automation.register_action(
|
||||||
@@ -73,7 +64,7 @@ async def bm8563_start_timer_to_code(
|
|||||||
return var
|
return var
|
||||||
|
|
||||||
|
|
||||||
@automation.register_action(
|
automation.register_parented_action(
|
||||||
"bm8563.read_time",
|
"bm8563.read_time",
|
||||||
ReadAction,
|
ReadAction,
|
||||||
automation.maybe_simple_id(
|
automation.maybe_simple_id(
|
||||||
@@ -83,15 +74,6 @@ async def bm8563_start_timer_to_code(
|
|||||||
),
|
),
|
||||||
synchronous=True,
|
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:
|
async def to_code(config: ConfigType) -> None:
|
||||||
|
|||||||
@@ -364,22 +364,36 @@ CC1101_ACTION_SCHEMA = cv.Schema(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@automation.register_action(
|
automation.register_parented_action(
|
||||||
"cc1101.begin_tx", BeginTxAction, CC1101_ACTION_SCHEMA, synchronous=True
|
"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):
|
def validate_raw_data(value):
|
||||||
|
|||||||
@@ -13,8 +13,6 @@ from esphome.const import (
|
|||||||
STATE_CLASS_MEASUREMENT,
|
STATE_CLASS_MEASUREMENT,
|
||||||
UNIT_PARTS_PER_MILLION,
|
UNIT_PARTS_PER_MILLION,
|
||||||
)
|
)
|
||||||
from esphome.core import ID
|
|
||||||
from esphome.cpp_generator import MockObj, TemplateArgsType
|
|
||||||
from esphome.types import ConfigType
|
from esphome.types import ConfigType
|
||||||
|
|
||||||
DEPENDENCIES = ["uart"]
|
DEPENDENCIES = ["uart"]
|
||||||
@@ -72,18 +70,9 @@ CALIBRATION_ACTION_SCHEMA = maybe_simple_id(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@automation.register_action(
|
automation.register_simple_action(
|
||||||
"cm1106.calibrate_zero",
|
"cm1106.calibrate_zero",
|
||||||
CM1106CalibrateZeroAction,
|
CM1106CalibrateZeroAction,
|
||||||
CALIBRATION_ACTION_SCHEMA,
|
CALIBRATION_ACTION_SCHEMA,
|
||||||
synchronous=True,
|
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_VOLT,
|
||||||
UNIT_WATT,
|
UNIT_WATT,
|
||||||
)
|
)
|
||||||
from esphome.core import ID
|
|
||||||
from esphome.cpp_generator import MockObj, TemplateArgsType
|
|
||||||
from esphome.types import ConfigType
|
from esphome.types import ConfigType
|
||||||
|
|
||||||
CODEOWNERS = ["@balrog-kun"]
|
CODEOWNERS = ["@balrog-kun"]
|
||||||
@@ -131,7 +129,7 @@ async def to_code(config: ConfigType) -> None:
|
|||||||
cg.add(var.set_power_sensor(sens))
|
cg.add(var.set_power_sensor(sens))
|
||||||
|
|
||||||
|
|
||||||
@automation.register_action(
|
automation.register_simple_action(
|
||||||
"cs5460a.restart",
|
"cs5460a.restart",
|
||||||
CS5460ARestartAction,
|
CS5460ARestartAction,
|
||||||
maybe_simple_id(
|
maybe_simple_id(
|
||||||
@@ -141,11 +139,3 @@ async def to_code(config: ConfigType) -> None:
|
|||||||
),
|
),
|
||||||
synchronous=True,
|
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",
|
"dfplayer.is_playing",
|
||||||
DFPlayerIsPlayingCondition,
|
DFPlayerIsPlayingCondition,
|
||||||
cv.Schema(
|
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)
|
await uart.register_uart_device(var, config)
|
||||||
|
|
||||||
|
|
||||||
@automation.register_action(
|
automation.register_parented_action(
|
||||||
"dfrobot_sen0395.reset",
|
"dfrobot_sen0395.reset",
|
||||||
DfrobotSen0395ResetAction,
|
DfrobotSen0395ResetAction,
|
||||||
maybe_simple_id(
|
maybe_simple_id(
|
||||||
@@ -59,16 +59,6 @@ async def to_code(config: ConfigType) -> None:
|
|||||||
),
|
),
|
||||||
synchronous=True,
|
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:
|
def range_segment_list(input: Any) -> list:
|
||||||
|
|||||||
@@ -294,74 +294,71 @@ MENU_ACTION_SCHEMA = maybe_simple_id(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@automation.register_action(
|
automation.register_simple_action(
|
||||||
"display_menu.up", UpAction, MENU_ACTION_SCHEMA, synchronous=True
|
"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(
|
automation.register_simple_action(
|
||||||
"display_menu.down", DownAction, MENU_ACTION_SCHEMA, synchronous=True
|
"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(
|
automation.register_simple_action(
|
||||||
"display_menu.left", LeftAction, MENU_ACTION_SCHEMA, synchronous=True
|
"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(
|
automation.register_simple_action(
|
||||||
"display_menu.right", RightAction, MENU_ACTION_SCHEMA, synchronous=True
|
"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(
|
automation.register_simple_action(
|
||||||
"display_menu.enter", EnterAction, MENU_ACTION_SCHEMA, synchronous=True
|
"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(
|
automation.register_simple_action(
|
||||||
"display_menu.show", ShowAction, MENU_ACTION_SCHEMA, synchronous=True
|
"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(
|
automation.register_simple_action(
|
||||||
"display_menu.hide", HideAction, MENU_ACTION_SCHEMA, synchronous=True
|
"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",
|
"display_menu.show_main",
|
||||||
ShowMainAction,
|
ShowMainAction,
|
||||||
MENU_ACTION_SCHEMA,
|
MENU_ACTION_SCHEMA,
|
||||||
synchronous=True,
|
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",
|
"display_menu.is_active",
|
||||||
IsActiveCondition,
|
IsActiveCondition,
|
||||||
automation.maybe_simple_id(
|
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):
|
async def menu_item_to_code(menu, config, parent):
|
||||||
|
|||||||
@@ -3,8 +3,6 @@ import esphome.codegen as cg
|
|||||||
from esphome.components import i2c, time
|
from esphome.components import i2c, time
|
||||||
import esphome.config_validation as cv
|
import esphome.config_validation as cv
|
||||||
from esphome.const import CONF_ID
|
from esphome.const import CONF_ID
|
||||||
from esphome.core import ID
|
|
||||||
from esphome.cpp_generator import MockObj, TemplateArgsType
|
|
||||||
from esphome.types import ConfigType
|
from esphome.types import ConfigType
|
||||||
|
|
||||||
CODEOWNERS = ["@badbadc0ffee"]
|
CODEOWNERS = ["@badbadc0ffee"]
|
||||||
@@ -22,7 +20,7 @@ CONFIG_SCHEMA = time.TIME_SCHEMA.extend(
|
|||||||
).extend(i2c.i2c_device_schema(0x68))
|
).extend(i2c.i2c_device_schema(0x68))
|
||||||
|
|
||||||
|
|
||||||
@automation.register_action(
|
automation.register_parented_action(
|
||||||
"ds1307.write_time",
|
"ds1307.write_time",
|
||||||
WriteAction,
|
WriteAction,
|
||||||
cv.Schema(
|
cv.Schema(
|
||||||
@@ -32,18 +30,9 @@ CONFIG_SCHEMA = time.TIME_SCHEMA.extend(
|
|||||||
),
|
),
|
||||||
synchronous=True,
|
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",
|
"ds1307.read_time",
|
||||||
ReadAction,
|
ReadAction,
|
||||||
automation.maybe_simple_id(
|
automation.maybe_simple_id(
|
||||||
@@ -53,15 +42,6 @@ async def ds1307_write_time_to_code(
|
|||||||
),
|
),
|
||||||
synchronous=True,
|
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:
|
async def to_code(config: ConfigType) -> None:
|
||||||
|
|||||||
@@ -1,10 +1,5 @@
|
|||||||
from esphome.automation import (
|
from esphome import automation
|
||||||
Action,
|
from esphome.automation import Action, Condition, maybe_simple_id, register_condition
|
||||||
Condition,
|
|
||||||
maybe_simple_id,
|
|
||||||
register_action,
|
|
||||||
register_condition,
|
|
||||||
)
|
|
||||||
import esphome.codegen as cg
|
import esphome.codegen as cg
|
||||||
from esphome.components import binary_sensor, sensor
|
from esphome.components import binary_sensor, sensor
|
||||||
import esphome.config_validation as cv
|
import esphome.config_validation as cv
|
||||||
@@ -93,46 +88,28 @@ DUTY_TIME_ID_SCHEMA = maybe_simple_id(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@register_action(
|
automation.register_parented_action(
|
||||||
"sensor.duty_time.start", StartAction, DUTY_TIME_ID_SCHEMA, synchronous=True
|
"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(
|
automation.register_parented_action(
|
||||||
"sensor.duty_time.stop", StopAction, DUTY_TIME_ID_SCHEMA, synchronous=True
|
"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(
|
automation.register_parented_action(
|
||||||
"sensor.duty_time.reset", ResetAction, DUTY_TIME_ID_SCHEMA, synchronous=True
|
"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(
|
@register_condition(
|
||||||
|
|||||||
@@ -32,8 +32,7 @@ from esphome.const import (
|
|||||||
CONF_NAME,
|
CONF_NAME,
|
||||||
CONF_NAME_ADD_MAC_SUFFIX,
|
CONF_NAME_ADD_MAC_SUFFIX,
|
||||||
)
|
)
|
||||||
from esphome.core import CORE, ID, TimePeriod
|
from esphome.core import CORE, TimePeriod
|
||||||
from esphome.cpp_generator import MockObj, TemplateArgsType
|
|
||||||
import esphome.final_validate as fv
|
import esphome.final_validate as fv
|
||||||
from esphome.types import ConfigType
|
from esphome.types import ConfigType
|
||||||
|
|
||||||
@@ -606,38 +605,27 @@ async def to_code(config: ConfigType) -> None:
|
|||||||
cg.add_define("USE_ESP32_BLE_UUID")
|
cg.add_define("USE_ESP32_BLE_UUID")
|
||||||
|
|
||||||
|
|
||||||
@automation.register_condition("ble.enabled", BLEEnabledCondition, cv.Schema({}))
|
automation.register_bare_condition(
|
||||||
async def ble_enabled_to_code(
|
"ble.enabled",
|
||||||
config: ConfigType,
|
BLEEnabledCondition,
|
||||||
condition_id: ID,
|
cv.Schema({}),
|
||||||
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
|
|
||||||
)
|
)
|
||||||
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(
|
automation.register_bare_action(
|
||||||
"ble.disable", BLEDisableAction, cv.Schema({}), synchronous=True
|
"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
|
# 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 (
|
from esphome.core import (
|
||||||
CORE,
|
CORE,
|
||||||
ID,
|
|
||||||
CoroPriority,
|
CoroPriority,
|
||||||
TimePeriodMilliseconds,
|
TimePeriodMilliseconds,
|
||||||
coroutine_with_priority,
|
coroutine_with_priority,
|
||||||
)
|
)
|
||||||
from esphome.cpp_generator import MockObj, TemplateArgsType
|
|
||||||
import esphome.final_validate as fv
|
import esphome.final_validate as fv
|
||||||
from esphome.types import ConfigType
|
from esphome.types import ConfigType
|
||||||
|
|
||||||
@@ -924,24 +922,15 @@ def _filter_source_files() -> list[str]:
|
|||||||
FILTER_SOURCE_FILES = _filter_source_files
|
FILTER_SOURCE_FILES = _filter_source_files
|
||||||
|
|
||||||
|
|
||||||
async def _new_pvariable_to_code(
|
automation.register_bare_condition(
|
||||||
config: ConfigType,
|
"ethernet.connected", EthernetConnectedCondition, cv.Schema({})
|
||||||
id_: ID,
|
)
|
||||||
template_arg: cg.TemplateArguments,
|
automation.register_bare_condition(
|
||||||
args: TemplateArgsType,
|
"ethernet.enabled", EthernetEnabledCondition, cv.Schema({})
|
||||||
) -> MockObj:
|
)
|
||||||
return cg.new_Pvariable(id_, template_arg)
|
automation.register_bare_action(
|
||||||
|
"ethernet.enable", EthernetEnableAction, cv.Schema({}), synchronous=True
|
||||||
|
)
|
||||||
for _name, _cls in (
|
automation.register_bare_action(
|
||||||
("ethernet.connected", EthernetConnectedCondition),
|
"ethernet.disable", EthernetDisableAction, cv.Schema({}), synchronous=True
|
||||||
("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
|
|
||||||
)
|
|
||||||
|
|||||||
@@ -80,72 +80,52 @@ EzoPMPArbitraryCommandAction = ezo_pmp_ns.class_(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@automation.register_action(
|
automation.register_simple_action(
|
||||||
"ezo_pmp.find",
|
"ezo_pmp.find",
|
||||||
EzoPMPFindAction,
|
EzoPMPFindAction,
|
||||||
EZO_PMP_NO_ARGS_ACTION_SCHEMA,
|
EZO_PMP_NO_ARGS_ACTION_SCHEMA,
|
||||||
synchronous=True,
|
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",
|
"ezo_pmp.dose_continuously",
|
||||||
EzoPMPDoseContinuouslyAction,
|
EzoPMPDoseContinuouslyAction,
|
||||||
EZO_PMP_NO_ARGS_ACTION_SCHEMA,
|
EZO_PMP_NO_ARGS_ACTION_SCHEMA,
|
||||||
synchronous=True,
|
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",
|
"ezo_pmp.clear_total_volume_dosed",
|
||||||
EzoPMPClearTotalVolumeDispensedAction,
|
EzoPMPClearTotalVolumeDispensedAction,
|
||||||
EZO_PMP_NO_ARGS_ACTION_SCHEMA,
|
EZO_PMP_NO_ARGS_ACTION_SCHEMA,
|
||||||
synchronous=True,
|
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",
|
"ezo_pmp.clear_calibration",
|
||||||
EzoPMPClearCalibrationAction,
|
EzoPMPClearCalibrationAction,
|
||||||
EZO_PMP_NO_ARGS_ACTION_SCHEMA,
|
EZO_PMP_NO_ARGS_ACTION_SCHEMA,
|
||||||
synchronous=True,
|
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",
|
"ezo_pmp.pause_dosing",
|
||||||
EzoPMPPauseDosingAction,
|
EzoPMPPauseDosingAction,
|
||||||
EZO_PMP_NO_ARGS_ACTION_SCHEMA,
|
EZO_PMP_NO_ARGS_ACTION_SCHEMA,
|
||||||
synchronous=True,
|
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",
|
"ezo_pmp.stop_dosing",
|
||||||
EzoPMPStopDosingAction,
|
EzoPMPStopDosingAction,
|
||||||
EZO_PMP_NO_ARGS_ACTION_SCHEMA,
|
EZO_PMP_NO_ARGS_ACTION_SCHEMA,
|
||||||
synchronous=True,
|
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
|
# Actions that require Multiple Args
|
||||||
|
|||||||
@@ -206,7 +206,7 @@ async def fingerprint_grow_enroll_to_code(config, action_id, template_arg, args)
|
|||||||
return var
|
return var
|
||||||
|
|
||||||
|
|
||||||
@automation.register_action(
|
automation.register_parented_action(
|
||||||
"fingerprint_grow.cancel_enroll",
|
"fingerprint_grow.cancel_enroll",
|
||||||
CancelEnrollmentAction,
|
CancelEnrollmentAction,
|
||||||
cv.Schema(
|
cv.Schema(
|
||||||
@@ -216,10 +216,6 @@ async def fingerprint_grow_enroll_to_code(config, action_id, template_arg, args)
|
|||||||
),
|
),
|
||||||
synchronous=True,
|
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(
|
@automation.register_action(
|
||||||
@@ -243,7 +239,7 @@ async def fingerprint_grow_delete_to_code(config, action_id, template_arg, args)
|
|||||||
return var
|
return var
|
||||||
|
|
||||||
|
|
||||||
@automation.register_action(
|
automation.register_parented_action(
|
||||||
"fingerprint_grow.delete_all",
|
"fingerprint_grow.delete_all",
|
||||||
DeleteAllAction,
|
DeleteAllAction,
|
||||||
cv.Schema(
|
cv.Schema(
|
||||||
@@ -253,10 +249,6 @@ async def fingerprint_grow_delete_to_code(config, action_id, template_arg, args)
|
|||||||
),
|
),
|
||||||
synchronous=True,
|
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(
|
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
|
return var
|
||||||
|
|
||||||
|
|
||||||
@automation.register_action(
|
automation.register_parented_action(
|
||||||
"grove_tb6612fng.standby",
|
"grove_tb6612fng.standby",
|
||||||
GROVETB6612FNGMotorStandbyAction,
|
GROVETB6612FNGMotorStandbyAction,
|
||||||
cv.Schema(
|
cv.Schema(
|
||||||
@@ -136,14 +136,9 @@ async def grove_tb6612fng_stop_to_code(config, action_id, template_arg, args):
|
|||||||
),
|
),
|
||||||
synchronous=True,
|
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",
|
"grove_tb6612fng.no_standby",
|
||||||
GROVETB6612FNGMotorNoStandbyAction,
|
GROVETB6612FNGMotorNoStandbyAction,
|
||||||
cv.Schema(
|
cv.Schema(
|
||||||
@@ -153,11 +148,6 @@ async def grove_tb6612fng_standby_to_code(config, action_id, template_arg, args)
|
|||||||
),
|
),
|
||||||
synchronous=True,
|
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(
|
@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",
|
"climate.haier.display_on",
|
||||||
DisplayOnAction,
|
DisplayOnAction,
|
||||||
HAIER_BASE_ACTION_SCHEMA,
|
HAIER_BASE_ACTION_SCHEMA,
|
||||||
synchronous=True,
|
synchronous=True,
|
||||||
)
|
)
|
||||||
@automation.register_action(
|
|
||||||
|
|
||||||
|
automation.register_simple_action(
|
||||||
"climate.haier.display_off",
|
"climate.haier.display_off",
|
||||||
DisplayOffAction,
|
DisplayOffAction,
|
||||||
HAIER_BASE_ACTION_SCHEMA,
|
HAIER_BASE_ACTION_SCHEMA,
|
||||||
synchronous=True,
|
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",
|
"climate.haier.beeper_on",
|
||||||
BeeperOnAction,
|
BeeperOnAction,
|
||||||
HAIER_HON_BASE_ACTION_SCHEMA,
|
HAIER_HON_BASE_ACTION_SCHEMA,
|
||||||
synchronous=True,
|
synchronous=True,
|
||||||
)
|
)
|
||||||
@automation.register_action(
|
|
||||||
|
|
||||||
|
automation.register_simple_action(
|
||||||
"climate.haier.beeper_off",
|
"climate.haier.beeper_off",
|
||||||
BeeperOffAction,
|
BeeperOffAction,
|
||||||
HAIER_HON_BASE_ACTION_SCHEMA,
|
HAIER_HON_BASE_ACTION_SCHEMA,
|
||||||
synchronous=True,
|
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
|
# Start self cleaning or steri-cleaning action action
|
||||||
@automation.register_action(
|
automation.register_simple_action(
|
||||||
"climate.haier.start_self_cleaning",
|
"climate.haier.start_self_cleaning",
|
||||||
StartSelfCleaningAction,
|
StartSelfCleaningAction,
|
||||||
HAIER_HON_BASE_ACTION_SCHEMA,
|
HAIER_HON_BASE_ACTION_SCHEMA,
|
||||||
synchronous=True,
|
synchronous=True,
|
||||||
)
|
)
|
||||||
@automation.register_action(
|
|
||||||
|
|
||||||
|
automation.register_simple_action(
|
||||||
"climate.haier.start_steri_cleaning",
|
"climate.haier.start_steri_cleaning",
|
||||||
StartSteriCleaningAction,
|
StartSteriCleaningAction,
|
||||||
HAIER_HON_BASE_ACTION_SCHEMA,
|
HAIER_HON_BASE_ACTION_SCHEMA,
|
||||||
synchronous=True,
|
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
|
# Set vertical airflow direction action
|
||||||
@@ -384,44 +381,44 @@ async def haier_set_horizontal_airflow_to_code(config, action_id, template_arg,
|
|||||||
return var
|
return var
|
||||||
|
|
||||||
|
|
||||||
@automation.register_action(
|
automation.register_simple_action(
|
||||||
"climate.haier.health_on",
|
"climate.haier.health_on",
|
||||||
HealthOnAction,
|
HealthOnAction,
|
||||||
HAIER_BASE_ACTION_SCHEMA,
|
HAIER_BASE_ACTION_SCHEMA,
|
||||||
synchronous=True,
|
synchronous=True,
|
||||||
)
|
)
|
||||||
@automation.register_action(
|
|
||||||
|
|
||||||
|
automation.register_simple_action(
|
||||||
"climate.haier.health_off",
|
"climate.haier.health_off",
|
||||||
HealthOffAction,
|
HealthOffAction,
|
||||||
HAIER_BASE_ACTION_SCHEMA,
|
HAIER_BASE_ACTION_SCHEMA,
|
||||||
synchronous=True,
|
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",
|
"climate.haier.power_on",
|
||||||
PowerOnAction,
|
PowerOnAction,
|
||||||
HAIER_BASE_ACTION_SCHEMA,
|
HAIER_BASE_ACTION_SCHEMA,
|
||||||
synchronous=True,
|
synchronous=True,
|
||||||
)
|
)
|
||||||
@automation.register_action(
|
|
||||||
|
|
||||||
|
automation.register_simple_action(
|
||||||
"climate.haier.power_off",
|
"climate.haier.power_off",
|
||||||
PowerOffAction,
|
PowerOffAction,
|
||||||
HAIER_BASE_ACTION_SCHEMA,
|
HAIER_BASE_ACTION_SCHEMA,
|
||||||
synchronous=True,
|
synchronous=True,
|
||||||
)
|
)
|
||||||
@automation.register_action(
|
|
||||||
|
|
||||||
|
automation.register_simple_action(
|
||||||
"climate.haier.power_toggle",
|
"climate.haier.power_toggle",
|
||||||
PowerToggleAction,
|
PowerToggleAction,
|
||||||
HAIER_BASE_ACTION_SCHEMA,
|
HAIER_BASE_ACTION_SCHEMA,
|
||||||
synchronous=True,
|
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:
|
def _final_validate(config) -> None:
|
||||||
|
|||||||
@@ -7,14 +7,11 @@ import esphome.config_validation as cv
|
|||||||
from esphome.const import (
|
from esphome.const import (
|
||||||
CONF_DECAY_MODE,
|
CONF_DECAY_MODE,
|
||||||
CONF_ENABLE_PIN,
|
CONF_ENABLE_PIN,
|
||||||
CONF_ID,
|
|
||||||
CONF_PIN_A,
|
CONF_PIN_A,
|
||||||
CONF_PIN_B,
|
CONF_PIN_B,
|
||||||
CONF_PRESET_MODES,
|
CONF_PRESET_MODES,
|
||||||
CONF_SPEED_COUNT,
|
CONF_SPEED_COUNT,
|
||||||
)
|
)
|
||||||
from esphome.core import ID
|
|
||||||
from esphome.cpp_generator import MockObj, TemplateArgsType
|
|
||||||
from esphome.types import ConfigType
|
from esphome.types import ConfigType
|
||||||
|
|
||||||
from .. import hbridge_ns
|
from .. import hbridge_ns
|
||||||
@@ -51,20 +48,12 @@ CONFIG_SCHEMA = (
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@automation.register_action(
|
automation.register_simple_action(
|
||||||
"fan.hbridge.brake",
|
"fan.hbridge.brake",
|
||||||
BrakeAction,
|
BrakeAction,
|
||||||
maybe_simple_id({cv.GenerateID(): cv.use_id(HBridgeFan)}),
|
maybe_simple_id({cv.GenerateID(): cv.use_id(HBridgeFan)}),
|
||||||
synchronous=True,
|
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:
|
async def to_code(config: ConfigType) -> None:
|
||||||
|
|||||||
@@ -139,18 +139,9 @@ async def hdc302x_heater_on_to_code(
|
|||||||
return var
|
return var
|
||||||
|
|
||||||
|
|
||||||
@automation.register_action(
|
automation.register_parented_action(
|
||||||
"hdc302x.heater_off",
|
"hdc302x.heater_off",
|
||||||
HeaterOffAction,
|
HeaterOffAction,
|
||||||
HDC302X_ACTION_SCHEMA,
|
HDC302X_ACTION_SCHEMA,
|
||||||
synchronous=True,
|
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]))
|
cg.add(var.set_restore(config[CONF_RESTORE]))
|
||||||
|
|
||||||
|
|
||||||
@automation.register_action(
|
automation.register_parented_action(
|
||||||
"sensor.integration.reset",
|
"sensor.integration.reset",
|
||||||
ResetAction,
|
ResetAction,
|
||||||
automation.maybe_simple_id(
|
automation.maybe_simple_id(
|
||||||
@@ -116,15 +116,6 @@ async def to_code(config: ConfigType) -> None:
|
|||||||
),
|
),
|
||||||
synchronous=True,
|
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(
|
@automation.register_action(
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ from esphome.const import (
|
|||||||
CONF_TIMEOUT,
|
CONF_TIMEOUT,
|
||||||
CONF_TRIGGER_ID,
|
CONF_TRIGGER_ID,
|
||||||
)
|
)
|
||||||
from esphome.core import ID
|
|
||||||
from esphome.cpp_generator import MockObj, literal
|
from esphome.cpp_generator import MockObj, literal
|
||||||
from esphome.types import ConfigType, TemplateArgsType
|
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]))
|
cg.add(var.set_enabled(config[CONF_ENABLE_ON_BOOT]))
|
||||||
|
|
||||||
|
|
||||||
@automation.register_action(
|
automation.register_parented_action(
|
||||||
"key_collector.enable",
|
"key_collector.enable",
|
||||||
EnableAction,
|
EnableAction,
|
||||||
automation.maybe_simple_id(
|
automation.maybe_simple_id(
|
||||||
@@ -145,18 +144,9 @@ async def to_code(config: ConfigType) -> None:
|
|||||||
),
|
),
|
||||||
synchronous=True,
|
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",
|
"key_collector.disable",
|
||||||
DisableAction,
|
DisableAction,
|
||||||
automation.maybe_simple_id(
|
automation.maybe_simple_id(
|
||||||
@@ -166,12 +156,3 @@ async def enable_to_code(
|
|||||||
),
|
),
|
||||||
synchronous=True,
|
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_PERCENT,
|
||||||
UNIT_VOLT,
|
UNIT_VOLT,
|
||||||
)
|
)
|
||||||
from esphome.core import ID
|
|
||||||
from esphome.cpp_generator import MockObj, TemplateArgsType
|
|
||||||
from esphome.types import ConfigType
|
from esphome.types import ConfigType
|
||||||
|
|
||||||
DEPENDENCIES = ["i2c"]
|
DEPENDENCIES = ["i2c"]
|
||||||
@@ -74,14 +72,9 @@ MAX17043_ACTION_SCHEMA = maybe_simple_id(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@automation.register_action(
|
automation.register_simple_action(
|
||||||
"max17043.sleep_mode", SleepAction, MAX17043_ACTION_SCHEMA, synchronous=True
|
"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(
|
automation.register_simple_action(
|
||||||
"mcp4461.wiper.increase", WiperIncreaseAction, WIPER_ACTION_SCHEMA, synchronous=True
|
"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",
|
"mcp4461.wiper.store_nonvolatile",
|
||||||
WiperStoreNonvolatileAction,
|
WiperStoreNonvolatileAction,
|
||||||
WIPER_ACTION_SCHEMA,
|
WIPER_ACTION_SCHEMA,
|
||||||
synchronous=True,
|
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(
|
@automation.register_action(
|
||||||
|
|||||||
@@ -122,33 +122,28 @@ NO_ARGS_ACTION_SCHEMA = maybe_simple_id(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@automation.register_action(
|
automation.register_parented_action(
|
||||||
"mhz19.calibrate_zero",
|
"mhz19.calibrate_zero",
|
||||||
MHZ19CalibrateZeroAction,
|
MHZ19CalibrateZeroAction,
|
||||||
NO_ARGS_ACTION_SCHEMA,
|
NO_ARGS_ACTION_SCHEMA,
|
||||||
synchronous=True,
|
synchronous=True,
|
||||||
)
|
)
|
||||||
@automation.register_action(
|
|
||||||
|
|
||||||
|
automation.register_parented_action(
|
||||||
"mhz19.abc_enable",
|
"mhz19.abc_enable",
|
||||||
MHZ19ABCEnableAction,
|
MHZ19ABCEnableAction,
|
||||||
NO_ARGS_ACTION_SCHEMA,
|
NO_ARGS_ACTION_SCHEMA,
|
||||||
synchronous=True,
|
synchronous=True,
|
||||||
)
|
)
|
||||||
@automation.register_action(
|
|
||||||
|
|
||||||
|
automation.register_parented_action(
|
||||||
"mhz19.abc_disable",
|
"mhz19.abc_disable",
|
||||||
MHZ19ABCDisableAction,
|
MHZ19ABCDisableAction,
|
||||||
NO_ARGS_ACTION_SCHEMA,
|
NO_ARGS_ACTION_SCHEMA,
|
||||||
synchronous=True,
|
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(
|
RANGE_ACTION_SCHEMA = maybe_simple_id(
|
||||||
|
|||||||
@@ -162,21 +162,12 @@ async def remote_temperature_action_to_code(
|
|||||||
return var
|
return var
|
||||||
|
|
||||||
|
|
||||||
@automation.register_action(
|
automation.register_parented_action(
|
||||||
f"{DOMAIN}.clear_remote_temperature",
|
f"{DOMAIN}.clear_remote_temperature",
|
||||||
ClearRemoteTemperatureAction,
|
ClearRemoteTemperatureAction,
|
||||||
CLEAR_REMOTE_TEMPERATURE_ACTION_SCHEMA,
|
CLEAR_REMOTE_TEMPERATURE_ACTION_SCHEMA,
|
||||||
synchronous=True,
|
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(
|
VANE_CONTROL_ACTION_SCHEMA = cv.Schema(
|
||||||
|
|||||||
@@ -4,8 +4,6 @@ import esphome.codegen as cg
|
|||||||
from esphome.components import i2c, sensor
|
from esphome.components import i2c, sensor
|
||||||
import esphome.config_validation as cv
|
import esphome.config_validation as cv
|
||||||
from esphome.const import CONF_GAIN, CONF_ID, ICON_SCALE, STATE_CLASS_MEASUREMENT
|
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
|
from esphome.types import ConfigType
|
||||||
|
|
||||||
CODEOWNERS = ["@cujomalainey"]
|
CODEOWNERS = ["@cujomalainey"]
|
||||||
@@ -116,30 +114,25 @@ NAU7802_CALIBRATE_SCHEMA = maybe_simple_id(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@automation.register_action(
|
automation.register_parented_action(
|
||||||
"nau7802.calibrate_internal_offset",
|
"nau7802.calibrate_internal_offset",
|
||||||
NAU7802CalbrateInternalOffsetAction,
|
NAU7802CalbrateInternalOffsetAction,
|
||||||
NAU7802_CALIBRATE_SCHEMA,
|
NAU7802_CALIBRATE_SCHEMA,
|
||||||
synchronous=True,
|
synchronous=True,
|
||||||
)
|
)
|
||||||
@automation.register_action(
|
|
||||||
|
|
||||||
|
automation.register_parented_action(
|
||||||
"nau7802.calibrate_external_offset",
|
"nau7802.calibrate_external_offset",
|
||||||
NAU7802CalbrateExternalOffsetAction,
|
NAU7802CalbrateExternalOffsetAction,
|
||||||
NAU7802_CALIBRATE_SCHEMA,
|
NAU7802_CALIBRATE_SCHEMA,
|
||||||
synchronous=True,
|
synchronous=True,
|
||||||
)
|
)
|
||||||
@automation.register_action(
|
|
||||||
|
|
||||||
|
automation.register_parented_action(
|
||||||
"nau7802.calibrate_gain",
|
"nau7802.calibrate_gain",
|
||||||
NAU7802CalbrateGainAction,
|
NAU7802CalbrateGainAction,
|
||||||
NAU7802_CALIBRATE_SCHEMA,
|
NAU7802_CALIBRATE_SCHEMA,
|
||||||
synchronous=True,
|
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
|
from esphome.components import i2c, time
|
||||||
import esphome.config_validation as cv
|
import esphome.config_validation as cv
|
||||||
from esphome.const import CONF_ID
|
from esphome.const import CONF_ID
|
||||||
from esphome.core import ID
|
|
||||||
from esphome.cpp_generator import MockObj, TemplateArgsType
|
|
||||||
from esphome.types import ConfigType
|
from esphome.types import ConfigType
|
||||||
|
|
||||||
CODEOWNERS = ["@brogon"]
|
CODEOWNERS = ["@brogon"]
|
||||||
@@ -24,7 +22,7 @@ CONFIG_SCHEMA = time.TIME_SCHEMA.extend(
|
|||||||
).extend(i2c.i2c_device_schema(0x51))
|
).extend(i2c.i2c_device_schema(0x51))
|
||||||
|
|
||||||
|
|
||||||
@automation.register_action(
|
automation.register_parented_action(
|
||||||
"pcf85063.write_time",
|
"pcf85063.write_time",
|
||||||
WriteAction,
|
WriteAction,
|
||||||
cv.Schema(
|
cv.Schema(
|
||||||
@@ -34,18 +32,9 @@ CONFIG_SCHEMA = time.TIME_SCHEMA.extend(
|
|||||||
),
|
),
|
||||||
synchronous=True,
|
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",
|
"pcf85063.read_time",
|
||||||
ReadAction,
|
ReadAction,
|
||||||
automation.maybe_simple_id(
|
automation.maybe_simple_id(
|
||||||
@@ -55,15 +44,6 @@ async def pcf85063_write_time_to_code(
|
|||||||
),
|
),
|
||||||
synchronous=True,
|
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:
|
async def to_code(config: ConfigType) -> None:
|
||||||
|
|||||||
@@ -3,8 +3,6 @@ import esphome.codegen as cg
|
|||||||
from esphome.components import i2c, time
|
from esphome.components import i2c, time
|
||||||
import esphome.config_validation as cv
|
import esphome.config_validation as cv
|
||||||
from esphome.const import CONF_ID
|
from esphome.const import CONF_ID
|
||||||
from esphome.core import ID
|
|
||||||
from esphome.cpp_generator import MockObj, TemplateArgsType
|
|
||||||
from esphome.types import ConfigType
|
from esphome.types import ConfigType
|
||||||
|
|
||||||
CODEOWNERS = ["@KoenBreeman"]
|
CODEOWNERS = ["@KoenBreeman"]
|
||||||
@@ -27,7 +25,7 @@ CONFIG_SCHEMA = time.TIME_SCHEMA.extend(
|
|||||||
).extend(i2c.i2c_device_schema(0x51))
|
).extend(i2c.i2c_device_schema(0x51))
|
||||||
|
|
||||||
|
|
||||||
@automation.register_action(
|
automation.register_parented_action(
|
||||||
"pcf8563.write_time",
|
"pcf8563.write_time",
|
||||||
WriteAction,
|
WriteAction,
|
||||||
automation.maybe_simple_id(
|
automation.maybe_simple_id(
|
||||||
@@ -37,18 +35,9 @@ CONFIG_SCHEMA = time.TIME_SCHEMA.extend(
|
|||||||
),
|
),
|
||||||
synchronous=True,
|
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",
|
"pcf8563.read_time",
|
||||||
ReadAction,
|
ReadAction,
|
||||||
automation.maybe_simple_id(
|
automation.maybe_simple_id(
|
||||||
@@ -58,15 +47,6 @@ async def pcf8563_write_time_to_code(
|
|||||||
),
|
),
|
||||||
synchronous=True,
|
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:
|
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",
|
"pmwcs3.air_calibration",
|
||||||
PMWCS3AirCalibrationAction,
|
PMWCS3AirCalibrationAction,
|
||||||
PMWCS3_CALIBRATION_SCHEMA,
|
PMWCS3_CALIBRATION_SCHEMA,
|
||||||
synchronous=True,
|
synchronous=True,
|
||||||
)
|
)
|
||||||
@automation.register_action(
|
|
||||||
|
|
||||||
|
automation.register_simple_action(
|
||||||
"pmwcs3.water_calibration",
|
"pmwcs3.water_calibration",
|
||||||
PMWCS3WaterCalibrationAction,
|
PMWCS3WaterCalibrationAction,
|
||||||
PMWCS3_CALIBRATION_SCHEMA,
|
PMWCS3_CALIBRATION_SCHEMA,
|
||||||
synchronous=True,
|
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(
|
PMWCS3_NEW_I2C_ADDRESS_SCHEMA = cv.maybe_simple_value(
|
||||||
|
|||||||
@@ -3,14 +3,12 @@ import esphome.codegen as cg
|
|||||||
from esphome.components import nfc
|
from esphome.components import nfc
|
||||||
import esphome.config_validation as cv
|
import esphome.config_validation as cv
|
||||||
from esphome.const import (
|
from esphome.const import (
|
||||||
CONF_ID,
|
|
||||||
CONF_ON_FINISHED_WRITE,
|
CONF_ON_FINISHED_WRITE,
|
||||||
CONF_ON_TAG,
|
CONF_ON_TAG,
|
||||||
CONF_ON_TAG_REMOVED,
|
CONF_ON_TAG_REMOVED,
|
||||||
CONF_TRIGGER_ID,
|
CONF_TRIGGER_ID,
|
||||||
)
|
)
|
||||||
from esphome.core import ID
|
from esphome.cpp_generator import MockObj
|
||||||
from esphome.cpp_generator import MockObj, TemplateArgsType
|
|
||||||
from esphome.types import ConfigType
|
from esphome.types import ConfigType
|
||||||
|
|
||||||
CODEOWNERS = ["@OttoWinter", "@jesserockz"]
|
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)
|
await automation.build_callback_automations(var, config, _CALLBACK_AUTOMATIONS)
|
||||||
|
|
||||||
|
|
||||||
@automation.register_condition(
|
automation.register_parented_condition(
|
||||||
"pn532.is_writing",
|
"pn532.is_writing",
|
||||||
PN532IsWritingCondition,
|
PN532IsWritingCondition,
|
||||||
cv.Schema(
|
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
|
return var
|
||||||
|
|
||||||
|
|
||||||
@automation.register_action(
|
automation.register_parented_action(
|
||||||
"tag.emulation_off",
|
"tag.emulation_off",
|
||||||
EmulationOffAction,
|
EmulationOffAction,
|
||||||
SIMPLE_ACTION_SCHEMA,
|
SIMPLE_ACTION_SCHEMA,
|
||||||
synchronous=True,
|
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",
|
"tag.set_clean_mode",
|
||||||
SetCleanModeAction,
|
SetCleanModeAction,
|
||||||
SIMPLE_ACTION_SCHEMA,
|
SIMPLE_ACTION_SCHEMA,
|
||||||
synchronous=True,
|
synchronous=True,
|
||||||
)
|
)
|
||||||
@automation.register_action(
|
|
||||||
|
|
||||||
|
automation.register_parented_action(
|
||||||
"tag.set_format_mode",
|
"tag.set_format_mode",
|
||||||
SetFormatModeAction,
|
SetFormatModeAction,
|
||||||
SIMPLE_ACTION_SCHEMA,
|
SIMPLE_ACTION_SCHEMA,
|
||||||
synchronous=True,
|
synchronous=True,
|
||||||
)
|
)
|
||||||
@automation.register_action(
|
|
||||||
|
|
||||||
|
automation.register_parented_action(
|
||||||
"tag.set_read_mode",
|
"tag.set_read_mode",
|
||||||
SetReadModeAction,
|
SetReadModeAction,
|
||||||
SIMPLE_ACTION_SCHEMA,
|
SIMPLE_ACTION_SCHEMA,
|
||||||
synchronous=True,
|
synchronous=True,
|
||||||
)
|
)
|
||||||
@automation.register_action(
|
|
||||||
|
|
||||||
|
automation.register_parented_action(
|
||||||
"tag.set_write_mode",
|
"tag.set_write_mode",
|
||||||
SetWriteModeAction,
|
SetWriteModeAction,
|
||||||
SIMPLE_ACTION_SCHEMA,
|
SIMPLE_ACTION_SCHEMA,
|
||||||
synchronous=True,
|
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 = (
|
_CALLBACK_AUTOMATIONS = (
|
||||||
@@ -220,7 +234,7 @@ async def setup_pn7150(var: MockObj, config: ConfigType) -> None:
|
|||||||
await automation.build_callback_automations(var, config, _CALLBACK_AUTOMATIONS)
|
await automation.build_callback_automations(var, config, _CALLBACK_AUTOMATIONS)
|
||||||
|
|
||||||
|
|
||||||
@automation.register_condition(
|
automation.register_parented_condition(
|
||||||
"pn7150.is_writing",
|
"pn7150.is_writing",
|
||||||
PN7150IsWritingCondition,
|
PN7150IsWritingCondition,
|
||||||
cv.Schema(
|
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
|
return var
|
||||||
|
|
||||||
|
|
||||||
@automation.register_action(
|
automation.register_parented_action(
|
||||||
"tag.emulation_off",
|
"tag.emulation_off",
|
||||||
EmulationOffAction,
|
EmulationOffAction,
|
||||||
SIMPLE_ACTION_SCHEMA,
|
SIMPLE_ACTION_SCHEMA,
|
||||||
synchronous=True,
|
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",
|
"tag.set_clean_mode",
|
||||||
SetCleanModeAction,
|
SetCleanModeAction,
|
||||||
SIMPLE_ACTION_SCHEMA,
|
SIMPLE_ACTION_SCHEMA,
|
||||||
synchronous=True,
|
synchronous=True,
|
||||||
)
|
)
|
||||||
@automation.register_action(
|
|
||||||
|
|
||||||
|
automation.register_parented_action(
|
||||||
"tag.set_format_mode",
|
"tag.set_format_mode",
|
||||||
SetFormatModeAction,
|
SetFormatModeAction,
|
||||||
SIMPLE_ACTION_SCHEMA,
|
SIMPLE_ACTION_SCHEMA,
|
||||||
synchronous=True,
|
synchronous=True,
|
||||||
)
|
)
|
||||||
@automation.register_action(
|
|
||||||
|
|
||||||
|
automation.register_parented_action(
|
||||||
"tag.set_read_mode",
|
"tag.set_read_mode",
|
||||||
SetReadModeAction,
|
SetReadModeAction,
|
||||||
SIMPLE_ACTION_SCHEMA,
|
SIMPLE_ACTION_SCHEMA,
|
||||||
synchronous=True,
|
synchronous=True,
|
||||||
)
|
)
|
||||||
@automation.register_action(
|
|
||||||
|
|
||||||
|
automation.register_parented_action(
|
||||||
"tag.set_write_mode",
|
"tag.set_write_mode",
|
||||||
SetWriteModeAction,
|
SetWriteModeAction,
|
||||||
SIMPLE_ACTION_SCHEMA,
|
SIMPLE_ACTION_SCHEMA,
|
||||||
synchronous=True,
|
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 = (
|
_CALLBACK_AUTOMATIONS = (
|
||||||
@@ -232,7 +246,7 @@ async def setup_pn7160(var: MockObj, config: ConfigType) -> None:
|
|||||||
await automation.build_callback_automations(var, config, _CALLBACK_AUTOMATIONS)
|
await automation.build_callback_automations(var, config, _CALLBACK_AUTOMATIONS)
|
||||||
|
|
||||||
|
|
||||||
@automation.register_condition(
|
automation.register_parented_condition(
|
||||||
"pn7160.is_writing",
|
"pn7160.is_writing",
|
||||||
PN7160IsWritingCondition,
|
PN7160IsWritingCondition,
|
||||||
cv.Schema(
|
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,
|
||||||
UNIT_WATT_HOURS,
|
UNIT_WATT_HOURS,
|
||||||
)
|
)
|
||||||
from esphome.core import ID
|
|
||||||
from esphome.cpp_generator import MockObj, TemplateArgsType
|
|
||||||
from esphome.types import ConfigType
|
from esphome.types import ConfigType
|
||||||
|
|
||||||
AUTO_LOAD = ["modbus"]
|
AUTO_LOAD = ["modbus"]
|
||||||
@@ -85,7 +83,7 @@ CONFIG_SCHEMA = (
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@automation.register_action(
|
automation.register_simple_action(
|
||||||
"pzemac.reset_energy",
|
"pzemac.reset_energy",
|
||||||
ResetEnergyAction,
|
ResetEnergyAction,
|
||||||
maybe_simple_id(
|
maybe_simple_id(
|
||||||
@@ -95,14 +93,6 @@ CONFIG_SCHEMA = (
|
|||||||
),
|
),
|
||||||
synchronous=True,
|
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:
|
def _final_validate(config: ConfigType) -> None:
|
||||||
|
|||||||
@@ -20,8 +20,6 @@ from esphome.const import (
|
|||||||
UNIT_VOLT,
|
UNIT_VOLT,
|
||||||
UNIT_WATT,
|
UNIT_WATT,
|
||||||
)
|
)
|
||||||
from esphome.core import ID
|
|
||||||
from esphome.cpp_generator import MockObj, TemplateArgsType
|
|
||||||
from esphome.types import ConfigType
|
from esphome.types import ConfigType
|
||||||
|
|
||||||
AUTO_LOAD = ["modbus"]
|
AUTO_LOAD = ["modbus"]
|
||||||
@@ -67,7 +65,7 @@ CONFIG_SCHEMA = (
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@automation.register_action(
|
automation.register_simple_action(
|
||||||
"pzemdc.reset_energy",
|
"pzemdc.reset_energy",
|
||||||
ResetEnergyAction,
|
ResetEnergyAction,
|
||||||
maybe_simple_id(
|
maybe_simple_id(
|
||||||
@@ -77,14 +75,6 @@ CONFIG_SCHEMA = (
|
|||||||
),
|
),
|
||||||
synchronous=True,
|
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:
|
def _final_validate(config: ConfigType) -> None:
|
||||||
|
|||||||
@@ -3,8 +3,6 @@ import esphome.codegen as cg
|
|||||||
from esphome.components import i2c, time
|
from esphome.components import i2c, time
|
||||||
import esphome.config_validation as cv
|
import esphome.config_validation as cv
|
||||||
from esphome.const import CONF_ID
|
from esphome.const import CONF_ID
|
||||||
from esphome.core import ID
|
|
||||||
from esphome.cpp_generator import MockObj, TemplateArgsType
|
|
||||||
from esphome.types import ConfigType
|
from esphome.types import ConfigType
|
||||||
|
|
||||||
CODEOWNERS = ["@beormund"]
|
CODEOWNERS = ["@beormund"]
|
||||||
@@ -22,7 +20,7 @@ CONFIG_SCHEMA = time.TIME_SCHEMA.extend(
|
|||||||
).extend(i2c.i2c_device_schema(0x32))
|
).extend(i2c.i2c_device_schema(0x32))
|
||||||
|
|
||||||
|
|
||||||
@automation.register_action(
|
automation.register_parented_action(
|
||||||
"rx8130.write_time",
|
"rx8130.write_time",
|
||||||
WriteAction,
|
WriteAction,
|
||||||
cv.Schema(
|
cv.Schema(
|
||||||
@@ -32,18 +30,9 @@ CONFIG_SCHEMA = time.TIME_SCHEMA.extend(
|
|||||||
),
|
),
|
||||||
synchronous=True,
|
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",
|
"rx8130.read_time",
|
||||||
ReadAction,
|
ReadAction,
|
||||||
automation.maybe_simple_id(
|
automation.maybe_simple_id(
|
||||||
@@ -53,15 +42,6 @@ async def rx8130_write_time_to_code(
|
|||||||
),
|
),
|
||||||
synchronous=True,
|
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:
|
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",
|
"scd4x.factory_reset",
|
||||||
FactoryResetAction,
|
FactoryResetAction,
|
||||||
SCD4X_RESET_ACTION_SCHEMA,
|
SCD4X_RESET_ACTION_SCHEMA,
|
||||||
synchronous=True,
|
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_MICROGRAMS_PER_CUBIC_METER,
|
||||||
UNIT_PERCENT,
|
UNIT_PERCENT,
|
||||||
)
|
)
|
||||||
from esphome.core import ID
|
|
||||||
from esphome.cpp_generator import MockObj, TemplateArgsType
|
|
||||||
from esphome.types import ConfigType
|
from esphome.types import ConfigType
|
||||||
|
|
||||||
CODEOWNERS = ["@martgras"]
|
CODEOWNERS = ["@martgras"]
|
||||||
@@ -282,17 +280,9 @@ SEN5X_ACTION_SCHEMA = maybe_simple_id(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@automation.register_action(
|
automation.register_simple_action(
|
||||||
"sen5x.start_fan_autoclean",
|
"sen5x.start_fan_autoclean",
|
||||||
StartFanAction,
|
StartFanAction,
|
||||||
SEN5X_ACTION_SCHEMA,
|
SEN5X_ACTION_SCHEMA,
|
||||||
synchronous=True,
|
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,
|
STATE_CLASS_MEASUREMENT,
|
||||||
UNIT_PARTS_PER_MILLION,
|
UNIT_PARTS_PER_MILLION,
|
||||||
)
|
)
|
||||||
from esphome.core import ID
|
|
||||||
from esphome.cpp_generator import MockObj, TemplateArgsType
|
|
||||||
from esphome.types import ConfigType
|
from esphome.types import ConfigType
|
||||||
|
|
||||||
DEPENDENCIES = ["uart"]
|
DEPENDENCIES = ["uart"]
|
||||||
@@ -82,41 +80,41 @@ CALIBRATION_ACTION_SCHEMA = maybe_simple_id(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@automation.register_action(
|
automation.register_simple_action(
|
||||||
"senseair.background_calibration",
|
"senseair.background_calibration",
|
||||||
SenseAirBackgroundCalibrationAction,
|
SenseAirBackgroundCalibrationAction,
|
||||||
CALIBRATION_ACTION_SCHEMA,
|
CALIBRATION_ACTION_SCHEMA,
|
||||||
synchronous=True,
|
synchronous=True,
|
||||||
)
|
)
|
||||||
@automation.register_action(
|
|
||||||
|
|
||||||
|
automation.register_simple_action(
|
||||||
"senseair.background_calibration_result",
|
"senseair.background_calibration_result",
|
||||||
SenseAirBackgroundCalibrationResultAction,
|
SenseAirBackgroundCalibrationResultAction,
|
||||||
CALIBRATION_ACTION_SCHEMA,
|
CALIBRATION_ACTION_SCHEMA,
|
||||||
synchronous=True,
|
synchronous=True,
|
||||||
)
|
)
|
||||||
@automation.register_action(
|
|
||||||
|
|
||||||
|
automation.register_simple_action(
|
||||||
"senseair.abc_enable",
|
"senseair.abc_enable",
|
||||||
SenseAirABCEnableAction,
|
SenseAirABCEnableAction,
|
||||||
CALIBRATION_ACTION_SCHEMA,
|
CALIBRATION_ACTION_SCHEMA,
|
||||||
synchronous=True,
|
synchronous=True,
|
||||||
)
|
)
|
||||||
@automation.register_action(
|
|
||||||
|
|
||||||
|
automation.register_simple_action(
|
||||||
"senseair.abc_disable",
|
"senseair.abc_disable",
|
||||||
SenseAirABCDisableAction,
|
SenseAirABCDisableAction,
|
||||||
CALIBRATION_ACTION_SCHEMA,
|
CALIBRATION_ACTION_SCHEMA,
|
||||||
synchronous=True,
|
synchronous=True,
|
||||||
)
|
)
|
||||||
@automation.register_action(
|
|
||||||
|
|
||||||
|
automation.register_simple_action(
|
||||||
"senseair.abc_get_period",
|
"senseair.abc_get_period",
|
||||||
SenseAirABCGetPeriodAction,
|
SenseAirABCGetPeriodAction,
|
||||||
CALIBRATION_ACTION_SCHEMA,
|
CALIBRATION_ACTION_SCHEMA,
|
||||||
synchronous=True,
|
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
|
return var
|
||||||
|
|
||||||
|
|
||||||
@automation.register_action(
|
automation.register_simple_action(
|
||||||
"sim800l.connect",
|
"sim800l.connect",
|
||||||
Sim800LConnectAction,
|
Sim800LConnectAction,
|
||||||
cv.Schema({cv.GenerateID(): cv.use_id(Sim800LComponent)}),
|
cv.Schema({cv.GenerateID(): cv.use_id(Sim800LComponent)}),
|
||||||
synchronous=True,
|
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(
|
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
|
return var
|
||||||
|
|
||||||
|
|
||||||
@automation.register_action(
|
automation.register_simple_action(
|
||||||
"sim800l.disconnect",
|
"sim800l.disconnect",
|
||||||
Sim800LDisconnectAction,
|
Sim800LDisconnectAction,
|
||||||
cv.Schema({cv.GenerateID(): cv.use_id(Sim800LComponent)}),
|
cv.Schema({cv.GenerateID(): cv.use_id(Sim800LComponent)}),
|
||||||
synchronous=True,
|
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,
|
STATE_CLASS_MEASUREMENT,
|
||||||
UNIT_DECIBEL,
|
UNIT_DECIBEL,
|
||||||
)
|
)
|
||||||
from esphome.core import ID
|
|
||||||
from esphome.cpp_generator import MockObj, TemplateArgsType
|
|
||||||
from esphome.types import ConfigType
|
from esphome.types import ConfigType
|
||||||
|
|
||||||
AUTO_LOAD = ["audio"]
|
AUTO_LOAD = ["audio"]
|
||||||
@@ -92,18 +90,17 @@ SOUND_LEVEL_ACTION_SCHEMA = automation.maybe_simple_id(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@automation.register_action(
|
automation.register_parented_action(
|
||||||
"sound_level.start", StartAction, SOUND_LEVEL_ACTION_SCHEMA, synchronous=True
|
"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",
|
"sprinkler.start_from_queue",
|
||||||
StartFromQueueAction,
|
StartFromQueueAction,
|
||||||
SPRINKLER_ACTION_SCHEMA,
|
SPRINKLER_ACTION_SCHEMA,
|
||||||
synchronous=True,
|
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",
|
"sprinkler.start_full_cycle",
|
||||||
StartFullCycleAction,
|
StartFullCycleAction,
|
||||||
SPRINKLER_ACTION_SCHEMA,
|
SPRINKLER_ACTION_SCHEMA,
|
||||||
synchronous=True,
|
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(
|
@automation.register_action(
|
||||||
@@ -485,45 +479,60 @@ async def sprinkler_start_single_valve_to_code(config, action_id, template_arg,
|
|||||||
return var
|
return var
|
||||||
|
|
||||||
|
|
||||||
@automation.register_action(
|
automation.register_simple_action(
|
||||||
"sprinkler.clear_queued_valves",
|
"sprinkler.clear_queued_valves",
|
||||||
ClearQueuedValvesAction,
|
ClearQueuedValvesAction,
|
||||||
SPRINKLER_ACTION_SCHEMA,
|
SPRINKLER_ACTION_SCHEMA,
|
||||||
synchronous=True,
|
synchronous=True,
|
||||||
)
|
)
|
||||||
@automation.register_action(
|
|
||||||
|
|
||||||
|
automation.register_simple_action(
|
||||||
"sprinkler.next_valve",
|
"sprinkler.next_valve",
|
||||||
NextValveAction,
|
NextValveAction,
|
||||||
SPRINKLER_ACTION_SCHEMA,
|
SPRINKLER_ACTION_SCHEMA,
|
||||||
synchronous=True,
|
synchronous=True,
|
||||||
)
|
)
|
||||||
@automation.register_action(
|
|
||||||
|
|
||||||
|
automation.register_simple_action(
|
||||||
"sprinkler.previous_valve",
|
"sprinkler.previous_valve",
|
||||||
PreviousValveAction,
|
PreviousValveAction,
|
||||||
SPRINKLER_ACTION_SCHEMA,
|
SPRINKLER_ACTION_SCHEMA,
|
||||||
synchronous=True,
|
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",
|
"sprinkler.resume_or_start_full_cycle",
|
||||||
ResumeOrStartAction,
|
ResumeOrStartAction,
|
||||||
SPRINKLER_ACTION_SCHEMA,
|
SPRINKLER_ACTION_SCHEMA,
|
||||||
synchronous=True,
|
synchronous=True,
|
||||||
)
|
)
|
||||||
@automation.register_action(
|
|
||||||
|
|
||||||
|
automation.register_simple_action(
|
||||||
"sprinkler.shutdown",
|
"sprinkler.shutdown",
|
||||||
ShutdownAction,
|
ShutdownAction,
|
||||||
SPRINKLER_ACTION_SCHEMA,
|
SPRINKLER_ACTION_SCHEMA,
|
||||||
synchronous=True,
|
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):
|
async def to_code(config):
|
||||||
|
|||||||
@@ -26,8 +26,6 @@ from esphome.const import (
|
|||||||
UNIT_MICROGRAMS_PER_CUBIC_METER,
|
UNIT_MICROGRAMS_PER_CUBIC_METER,
|
||||||
UNIT_MICROMETER,
|
UNIT_MICROMETER,
|
||||||
)
|
)
|
||||||
from esphome.core import ID
|
|
||||||
from esphome.cpp_generator import MockObj, TemplateArgsType
|
|
||||||
from esphome.types import ConfigType
|
from esphome.types import ConfigType
|
||||||
|
|
||||||
CODEOWNERS = ["@martgras"]
|
CODEOWNERS = ["@martgras"]
|
||||||
@@ -182,30 +180,25 @@ SPS30_ACTION_SCHEMA = maybe_simple_id(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@automation.register_action(
|
automation.register_parented_action(
|
||||||
"sps30.start_fan_autoclean",
|
"sps30.start_fan_autoclean",
|
||||||
StartFanAction,
|
StartFanAction,
|
||||||
SPS30_ACTION_SCHEMA,
|
SPS30_ACTION_SCHEMA,
|
||||||
synchronous=True,
|
synchronous=True,
|
||||||
)
|
)
|
||||||
@automation.register_action(
|
|
||||||
|
|
||||||
|
automation.register_parented_action(
|
||||||
"sps30.start_measurement",
|
"sps30.start_measurement",
|
||||||
StartMeasurementAction,
|
StartMeasurementAction,
|
||||||
SPS30_ACTION_SCHEMA,
|
SPS30_ACTION_SCHEMA,
|
||||||
synchronous=True,
|
synchronous=True,
|
||||||
)
|
)
|
||||||
@automation.register_action(
|
|
||||||
|
|
||||||
|
automation.register_parented_action(
|
||||||
"sps30.stop_measurement",
|
"sps30.stop_measurement",
|
||||||
StopMeasurementAction,
|
StopMeasurementAction,
|
||||||
SPS30_ACTION_SCHEMA,
|
SPS30_ACTION_SCHEMA,
|
||||||
synchronous=True,
|
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",
|
"sx126x.run_image_cal",
|
||||||
RunImageCalAction,
|
RunImageCalAction,
|
||||||
NO_ARGS_ACTION_SCHEMA,
|
NO_ARGS_ACTION_SCHEMA,
|
||||||
synchronous=True,
|
synchronous=True,
|
||||||
)
|
)
|
||||||
@automation.register_action(
|
|
||||||
|
|
||||||
|
automation.register_parented_action(
|
||||||
"sx126x.set_mode_tx",
|
"sx126x.set_mode_tx",
|
||||||
SetModeTxAction,
|
SetModeTxAction,
|
||||||
NO_ARGS_ACTION_SCHEMA,
|
NO_ARGS_ACTION_SCHEMA,
|
||||||
synchronous=True,
|
synchronous=True,
|
||||||
)
|
)
|
||||||
@automation.register_action(
|
|
||||||
|
|
||||||
|
automation.register_parented_action(
|
||||||
"sx126x.set_mode_rx",
|
"sx126x.set_mode_rx",
|
||||||
SetModeRxAction,
|
SetModeRxAction,
|
||||||
NO_ARGS_ACTION_SCHEMA,
|
NO_ARGS_ACTION_SCHEMA,
|
||||||
synchronous=True,
|
synchronous=True,
|
||||||
)
|
)
|
||||||
@automation.register_action(
|
|
||||||
|
|
||||||
|
automation.register_parented_action(
|
||||||
"sx126x.set_mode_standby",
|
"sx126x.set_mode_standby",
|
||||||
SetModeStandbyAction,
|
SetModeStandbyAction,
|
||||||
NO_ARGS_ACTION_SCHEMA,
|
NO_ARGS_ACTION_SCHEMA,
|
||||||
synchronous=True,
|
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(
|
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",
|
"sx127x.run_image_cal",
|
||||||
RunImageCalAction,
|
RunImageCalAction,
|
||||||
NO_ARGS_ACTION_SCHEMA,
|
NO_ARGS_ACTION_SCHEMA,
|
||||||
synchronous=True,
|
synchronous=True,
|
||||||
)
|
)
|
||||||
@automation.register_action(
|
|
||||||
|
|
||||||
|
automation.register_parented_action(
|
||||||
"sx127x.set_mode_tx",
|
"sx127x.set_mode_tx",
|
||||||
SetModeTxAction,
|
SetModeTxAction,
|
||||||
NO_ARGS_ACTION_SCHEMA,
|
NO_ARGS_ACTION_SCHEMA,
|
||||||
synchronous=True,
|
synchronous=True,
|
||||||
)
|
)
|
||||||
@automation.register_action(
|
|
||||||
|
|
||||||
|
automation.register_parented_action(
|
||||||
"sx127x.set_mode_rx",
|
"sx127x.set_mode_rx",
|
||||||
SetModeRxAction,
|
SetModeRxAction,
|
||||||
NO_ARGS_ACTION_SCHEMA,
|
NO_ARGS_ACTION_SCHEMA,
|
||||||
synchronous=True,
|
synchronous=True,
|
||||||
)
|
)
|
||||||
@automation.register_action(
|
|
||||||
|
|
||||||
|
automation.register_parented_action(
|
||||||
"sx127x.set_mode_sleep",
|
"sx127x.set_mode_sleep",
|
||||||
SetModeSleepAction,
|
SetModeSleepAction,
|
||||||
NO_ARGS_ACTION_SCHEMA,
|
NO_ARGS_ACTION_SCHEMA,
|
||||||
synchronous=True,
|
synchronous=True,
|
||||||
)
|
)
|
||||||
@automation.register_action(
|
|
||||||
|
|
||||||
|
automation.register_parented_action(
|
||||||
"sx127x.set_mode_standby",
|
"sx127x.set_mode_standby",
|
||||||
SetModeStandbyAction,
|
SetModeStandbyAction,
|
||||||
NO_ARGS_ACTION_SCHEMA,
|
NO_ARGS_ACTION_SCHEMA,
|
||||||
synchronous=True,
|
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(
|
SEND_PACKET_ACTION_SCHEMA = cv.maybe_simple_value(
|
||||||
|
|||||||
@@ -12,8 +12,6 @@ from esphome.components.esp32 import (
|
|||||||
)
|
)
|
||||||
import esphome.config_validation as cv
|
import esphome.config_validation as cv
|
||||||
from esphome.const import CONF_HARDWARE_UART, CONF_ID
|
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
|
from esphome.types import ConfigType
|
||||||
|
|
||||||
CODEOWNERS = ["@kbx81"]
|
CODEOWNERS = ["@kbx81"]
|
||||||
@@ -136,16 +134,8 @@ async def to_code(config: ConfigType) -> None:
|
|||||||
add_idf_sdkconfig_option("CONFIG_TINYUSB_DESC_BCD_DEVICE", 0x0100)
|
add_idf_sdkconfig_option("CONFIG_TINYUSB_DESC_BCD_DEVICE", 0x0100)
|
||||||
|
|
||||||
|
|
||||||
@automation.register_condition(
|
automation.register_simple_condition(
|
||||||
"tinyusb.is_mounted",
|
"tinyusb.is_mounted",
|
||||||
IsMountedCondition,
|
IsMountedCondition,
|
||||||
cv.Schema({cv.GenerateID(): cv.use_id(TinyUSB)}),
|
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
|
return var
|
||||||
|
|
||||||
|
|
||||||
@automation.register_action(
|
automation.register_parented_action(
|
||||||
"tm1651.turn_off",
|
"tm1651.turn_off",
|
||||||
TurnOffAction,
|
TurnOffAction,
|
||||||
BINARY_OUTPUT_ACTION_SCHEMA,
|
BINARY_OUTPUT_ACTION_SCHEMA,
|
||||||
synchronous=True,
|
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(
|
automation.register_parented_action(
|
||||||
"tm1651.turn_on", TurnOnAction, BINARY_OUTPUT_ACTION_SCHEMA, synchronous=True
|
"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",
|
"ufire_ec.reset",
|
||||||
UFireECResetAction,
|
UFireECResetAction,
|
||||||
UFIRE_EC_RESET_SCHEMA,
|
UFIRE_EC_RESET_SCHEMA,
|
||||||
synchronous=True,
|
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)})
|
UFIRE_ISE_RESET_SCHEMA = cv.Schema({cv.GenerateID(): cv.use_id(UFireISEComponent)})
|
||||||
|
|
||||||
|
|
||||||
@automation.register_action(
|
automation.register_simple_action(
|
||||||
"ufire_ise.reset",
|
"ufire_ise.reset",
|
||||||
UFireISEResetAction,
|
UFireISEResetAction,
|
||||||
UFIRE_ISE_RESET_SCHEMA,
|
UFIRE_ISE_RESET_SCHEMA,
|
||||||
synchronous=True,
|
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,
|
DEVICE_CLASS_FIRMWARE,
|
||||||
ENTITY_CATEGORY_CONFIG,
|
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 (
|
from esphome.core.entity_helpers import (
|
||||||
entity_duplicate_validator,
|
entity_duplicate_validator,
|
||||||
queue_entity_register,
|
queue_entity_register,
|
||||||
setup_device_class,
|
setup_device_class,
|
||||||
setup_entity,
|
setup_entity,
|
||||||
)
|
)
|
||||||
from esphome.cpp_generator import MockObj, MockObjClass, TemplateArgsType
|
from esphome.cpp_generator import MockObj, MockObjClass
|
||||||
from esphome.types import ConfigType
|
from esphome.types import ConfigType
|
||||||
|
|
||||||
CODEOWNERS = ["@jesserockz"]
|
CODEOWNERS = ["@jesserockz"]
|
||||||
@@ -144,7 +144,7 @@ automation.register_apply_action(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@automation.register_action(
|
automation.register_parented_action(
|
||||||
"update.check",
|
"update.check",
|
||||||
CheckAction,
|
CheckAction,
|
||||||
automation.maybe_simple_id(
|
automation.maybe_simple_id(
|
||||||
@@ -154,18 +154,9 @@ automation.register_apply_action(
|
|||||||
),
|
),
|
||||||
synchronous=True,
|
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",
|
"update.is_available",
|
||||||
IsAvailableCondition,
|
IsAvailableCondition,
|
||||||
automation.maybe_simple_id(
|
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(
|
automation.register_simple_action(
|
||||||
"valve.open", OpenAction, VALVE_ACTION_SCHEMA, synchronous=True
|
"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(
|
automation.register_simple_action(
|
||||||
"valve.close", CloseAction, VALVE_ACTION_SCHEMA, synchronous=True
|
"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(
|
automation.register_simple_action(
|
||||||
"valve.stop", StopAction, VALVE_ACTION_SCHEMA, synchronous=True
|
"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(
|
automation.register_simple_action(
|
||||||
"valve.toggle", ToggleAction, VALVE_ACTION_SCHEMA, synchronous=True
|
"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(
|
VALVE_CONTROL_ACTION_SCHEMA = cv.Schema(
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
from esphome import automation
|
from esphome import automation
|
||||||
from esphome.automation import register_condition
|
|
||||||
import esphome.codegen as cg
|
import esphome.codegen as cg
|
||||||
from esphome.components import media_player, micro_wake_word, microphone, speaker
|
from esphome.components import media_player, micro_wake_word, microphone, speaker
|
||||||
import esphome.config_validation as cv
|
import esphome.config_validation as cv
|
||||||
@@ -14,8 +13,6 @@ from esphome.const import (
|
|||||||
CONF_ON_START,
|
CONF_ON_START,
|
||||||
CONF_SPEAKER,
|
CONF_SPEAKER,
|
||||||
)
|
)
|
||||||
from esphome.core import ID
|
|
||||||
from esphome.cpp_generator import MockObj, TemplateArgsType
|
|
||||||
from esphome.types import ConfigType
|
from esphome.types import ConfigType
|
||||||
|
|
||||||
AUTO_LOAD = ["audio", "ring_buffer", "socket"]
|
AUTO_LOAD = ["audio", "ring_buffer", "socket"]
|
||||||
@@ -424,29 +421,15 @@ automation.register_apply_action(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@register_condition(
|
automation.register_parented_condition(
|
||||||
"voice_assistant.is_running", IsRunningCondition, VOICE_ASSISTANT_ACTION_SCHEMA
|
"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(
|
automation.register_parented_condition(
|
||||||
"voice_assistant.connected", ConnectedCondition, VOICE_ASSISTANT_ACTION_SCHEMA
|
"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 (
|
from esphome.core import (
|
||||||
CORE,
|
CORE,
|
||||||
ID,
|
|
||||||
CoroPriority,
|
CoroPriority,
|
||||||
EsphomeError,
|
EsphomeError,
|
||||||
HexInt,
|
HexInt,
|
||||||
coroutine_with_priority,
|
coroutine_with_priority,
|
||||||
)
|
)
|
||||||
import esphome.final_validate as fv
|
import esphome.final_validate as fv
|
||||||
from esphome.types import ConfigType, TemplateArgsType
|
from esphome.types import ConfigType
|
||||||
|
|
||||||
from . import wpa2_eap
|
from . import wpa2_eap
|
||||||
|
|
||||||
@@ -830,45 +829,49 @@ async def to_code(config):
|
|||||||
CORE.add_job(final_step)
|
CORE.add_job(final_step)
|
||||||
|
|
||||||
|
|
||||||
@automation.register_condition("wifi.connected", WiFiConnectedCondition, cv.Schema({}))
|
automation.register_bare_condition(
|
||||||
async def wifi_connected_to_code(config, condition_id, template_arg, args):
|
"wifi.connected",
|
||||||
return cg.new_Pvariable(condition_id, template_arg)
|
WiFiConnectedCondition,
|
||||||
|
cv.Schema({}),
|
||||||
|
|
||||||
@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
|
|
||||||
)
|
)
|
||||||
async def wifi_enable_to_code(config, action_id, template_arg, args):
|
|
||||||
return cg.new_Pvariable(action_id, template_arg)
|
|
||||||
|
|
||||||
|
|
||||||
@automation.register_action(
|
automation.register_bare_condition(
|
||||||
"wifi.disable", WiFiDisableAction, cv.Schema({}), synchronous=True
|
"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(
|
automation.register_bare_condition(
|
||||||
"wifi.roam", WiFiRoamAction, cv.Schema({}), synchronous=True
|
"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"
|
KEEP_SCAN_RESULTS_KEY = "wifi_keep_scan_results"
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import logging
|
import logging
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from esphome import automation, core
|
from esphome import automation
|
||||||
import esphome.codegen as cg
|
import esphome.codegen as cg
|
||||||
from esphome.components.esp32 import only_on_variant
|
from esphome.components.esp32 import only_on_variant
|
||||||
from esphome.components.esp32.const import (
|
from esphome.components.esp32.const import (
|
||||||
@@ -298,18 +298,9 @@ FactoryResetAction = zigbee_ns.class_(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@automation.register_action(
|
automation.register_parented_action(
|
||||||
"zigbee.factory_reset",
|
"zigbee.factory_reset",
|
||||||
FactoryResetAction,
|
FactoryResetAction,
|
||||||
ZIGBEE_ACTION_SCHEMA,
|
ZIGBEE_ACTION_SCHEMA,
|
||||||
synchronous=True,
|
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