mirror of
https://github.com/esphome/esphome.git
synced 2026-10-07 11:26:39 +00:00
[api] Cover Home Assistant action fields in the api test config (#20236)
This commit is contained in:
@@ -149,6 +149,38 @@ api:
|
||||
args:
|
||||
- error.c_str()
|
||||
- name.c_str()
|
||||
# Constant and lambda fields mixed in one action, with lambdas of several
|
||||
# return types reading the trigger args, and a templated action name
|
||||
- action: test_homeassistant_fields
|
||||
variables:
|
||||
room: string
|
||||
level: int
|
||||
then:
|
||||
- homeassistant.action:
|
||||
action: !lambda 'return std::string("light.") + (level > 0 ? "turn_on" : "turn_off");'
|
||||
data:
|
||||
entity_id: light.living_room
|
||||
brightness: !lambda 'return level;'
|
||||
data_template:
|
||||
message: "{{ room }} is at {{ level }}"
|
||||
variables:
|
||||
room: !lambda 'return room.c_str();'
|
||||
level: !lambda 'static char buf[12]; snprintf(buf, sizeof(buf), "%d", level); return buf;'
|
||||
- homeassistant.action:
|
||||
action: notify.html5
|
||||
data:
|
||||
message: Button was pressed
|
||||
# Same constant fields as above, so codegen can share them
|
||||
- homeassistant.action:
|
||||
action: notify.html5
|
||||
data:
|
||||
message: Button was pressed
|
||||
- homeassistant.event:
|
||||
event: esphome.room_level
|
||||
data:
|
||||
room: !lambda 'return room;'
|
||||
ratio: !lambda 'return level / 100.0f;'
|
||||
- homeassistant.tag_scanned: !lambda 'return room;'
|
||||
# Test ContinuationAction (IfAction with then/else branches)
|
||||
- action: test_if_action
|
||||
variables:
|
||||
|
||||
Reference in New Issue
Block a user