mirror of
https://github.com/home-assistant/core.git
synced 2026-04-12 20:56:18 +02:00
Compare commits
3 Commits
168007
...
add-automa
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5f6b60cb78 | ||
|
|
6b61984342 | ||
|
|
bad52f0824 |
@@ -4,11 +4,9 @@
|
||||
required: true
|
||||
default: any
|
||||
selector:
|
||||
select:
|
||||
automation_behavior:
|
||||
translation_key: condition_behavior
|
||||
options:
|
||||
- all
|
||||
- any
|
||||
mode: condition
|
||||
|
||||
# --- Number or entity selectors ---
|
||||
|
||||
|
||||
@@ -3,12 +3,9 @@
|
||||
required: true
|
||||
default: any
|
||||
selector:
|
||||
select:
|
||||
automation_behavior:
|
||||
translation_key: trigger_behavior
|
||||
options:
|
||||
- first
|
||||
- last
|
||||
- any
|
||||
mode: trigger
|
||||
|
||||
.number_or_entity_co: &number_or_entity_co
|
||||
required: false
|
||||
|
||||
@@ -7,11 +7,9 @@
|
||||
required: true
|
||||
default: any
|
||||
selector:
|
||||
select:
|
||||
automation_behavior:
|
||||
translation_key: condition_behavior
|
||||
options:
|
||||
- all
|
||||
- any
|
||||
mode: condition
|
||||
|
||||
is_armed: *condition_common
|
||||
|
||||
|
||||
@@ -7,12 +7,9 @@
|
||||
required: true
|
||||
default: any
|
||||
selector:
|
||||
select:
|
||||
options:
|
||||
- first
|
||||
- last
|
||||
- any
|
||||
automation_behavior:
|
||||
translation_key: trigger_behavior
|
||||
mode: trigger
|
||||
|
||||
armed: *trigger_common
|
||||
|
||||
|
||||
@@ -7,11 +7,9 @@
|
||||
required: true
|
||||
default: any
|
||||
selector:
|
||||
select:
|
||||
automation_behavior:
|
||||
translation_key: condition_behavior
|
||||
options:
|
||||
- all
|
||||
- any
|
||||
mode: condition
|
||||
|
||||
is_idle: *condition_common
|
||||
is_listening: *condition_common
|
||||
|
||||
@@ -7,12 +7,9 @@
|
||||
required: true
|
||||
default: any
|
||||
selector:
|
||||
select:
|
||||
options:
|
||||
- first
|
||||
- last
|
||||
- any
|
||||
automation_behavior:
|
||||
translation_key: trigger_behavior
|
||||
mode: trigger
|
||||
|
||||
idle: *trigger_common
|
||||
listening: *trigger_common
|
||||
|
||||
@@ -8,11 +8,9 @@
|
||||
required: true
|
||||
default: any
|
||||
selector:
|
||||
select:
|
||||
automation_behavior:
|
||||
translation_key: condition_behavior
|
||||
options:
|
||||
- all
|
||||
- any
|
||||
mode: condition
|
||||
|
||||
.number_or_entity: &number_or_entity
|
||||
required: false
|
||||
|
||||
@@ -7,11 +7,9 @@
|
||||
required: true
|
||||
default: any
|
||||
selector:
|
||||
select:
|
||||
automation_behavior:
|
||||
translation_key: condition_behavior
|
||||
options:
|
||||
- all
|
||||
- any
|
||||
mode: condition
|
||||
|
||||
.number_or_entity_humidity: &number_or_entity_humidity
|
||||
required: false
|
||||
|
||||
@@ -7,12 +7,9 @@
|
||||
required: true
|
||||
default: any
|
||||
selector:
|
||||
select:
|
||||
automation_behavior:
|
||||
translation_key: trigger_behavior
|
||||
options:
|
||||
- first
|
||||
- last
|
||||
- any
|
||||
mode: trigger
|
||||
|
||||
.number_or_entity_humidity: &number_or_entity_humidity
|
||||
required: false
|
||||
|
||||
@@ -3,11 +3,9 @@
|
||||
required: true
|
||||
default: any
|
||||
selector:
|
||||
select:
|
||||
automation_behavior:
|
||||
translation_key: condition_behavior
|
||||
options:
|
||||
- all
|
||||
- any
|
||||
mode: condition
|
||||
|
||||
awning_is_closed:
|
||||
fields: *condition_common_fields
|
||||
|
||||
@@ -3,12 +3,9 @@
|
||||
required: true
|
||||
default: any
|
||||
selector:
|
||||
select:
|
||||
automation_behavior:
|
||||
translation_key: trigger_behavior
|
||||
options:
|
||||
- first
|
||||
- last
|
||||
- any
|
||||
mode: trigger
|
||||
|
||||
awning_closed:
|
||||
fields: *trigger_common_fields
|
||||
|
||||
@@ -7,11 +7,9 @@
|
||||
required: true
|
||||
default: any
|
||||
selector:
|
||||
select:
|
||||
automation_behavior:
|
||||
translation_key: condition_behavior
|
||||
options:
|
||||
- all
|
||||
- any
|
||||
mode: condition
|
||||
|
||||
is_home: *condition_common
|
||||
is_not_home: *condition_common
|
||||
|
||||
@@ -7,12 +7,9 @@
|
||||
required: true
|
||||
default: any
|
||||
selector:
|
||||
select:
|
||||
options:
|
||||
- first
|
||||
- last
|
||||
- any
|
||||
automation_behavior:
|
||||
translation_key: trigger_behavior
|
||||
mode: trigger
|
||||
|
||||
entered_home: *trigger_common
|
||||
left_home: *trigger_common
|
||||
|
||||
@@ -3,11 +3,9 @@
|
||||
required: true
|
||||
default: any
|
||||
selector:
|
||||
select:
|
||||
automation_behavior:
|
||||
translation_key: condition_behavior
|
||||
options:
|
||||
- all
|
||||
- any
|
||||
mode: condition
|
||||
|
||||
is_closed:
|
||||
fields: *condition_common_fields
|
||||
|
||||
@@ -3,12 +3,9 @@
|
||||
required: true
|
||||
default: any
|
||||
selector:
|
||||
select:
|
||||
automation_behavior:
|
||||
translation_key: trigger_behavior
|
||||
options:
|
||||
- first
|
||||
- last
|
||||
- any
|
||||
mode: trigger
|
||||
|
||||
closed:
|
||||
fields: *trigger_common_fields
|
||||
|
||||
@@ -7,11 +7,9 @@
|
||||
required: true
|
||||
default: any
|
||||
selector:
|
||||
select:
|
||||
automation_behavior:
|
||||
translation_key: condition_behavior
|
||||
options:
|
||||
- all
|
||||
- any
|
||||
mode: condition
|
||||
|
||||
is_off: *condition_common
|
||||
is_on: *condition_common
|
||||
|
||||
@@ -7,12 +7,9 @@
|
||||
required: true
|
||||
default: any
|
||||
selector:
|
||||
select:
|
||||
options:
|
||||
- first
|
||||
- last
|
||||
- any
|
||||
automation_behavior:
|
||||
translation_key: trigger_behavior
|
||||
mode: trigger
|
||||
|
||||
turned_on: *trigger_common
|
||||
turned_off: *trigger_common
|
||||
|
||||
@@ -3,11 +3,9 @@
|
||||
required: true
|
||||
default: any
|
||||
selector:
|
||||
select:
|
||||
automation_behavior:
|
||||
translation_key: condition_behavior
|
||||
options:
|
||||
- all
|
||||
- any
|
||||
mode: condition
|
||||
|
||||
is_closed:
|
||||
fields: *condition_common_fields
|
||||
|
||||
@@ -3,12 +3,9 @@
|
||||
required: true
|
||||
default: any
|
||||
selector:
|
||||
select:
|
||||
automation_behavior:
|
||||
translation_key: trigger_behavior
|
||||
options:
|
||||
- first
|
||||
- last
|
||||
- any
|
||||
mode: trigger
|
||||
|
||||
closed:
|
||||
fields: *trigger_common_fields
|
||||
|
||||
@@ -3,11 +3,9 @@
|
||||
required: true
|
||||
default: any
|
||||
selector:
|
||||
select:
|
||||
automation_behavior:
|
||||
translation_key: condition_behavior
|
||||
options:
|
||||
- all
|
||||
- any
|
||||
mode: condition
|
||||
|
||||
is_closed:
|
||||
fields: *condition_common_fields
|
||||
|
||||
@@ -3,12 +3,9 @@
|
||||
required: true
|
||||
default: any
|
||||
selector:
|
||||
select:
|
||||
automation_behavior:
|
||||
translation_key: trigger_behavior
|
||||
options:
|
||||
- first
|
||||
- last
|
||||
- any
|
||||
mode: trigger
|
||||
|
||||
closed:
|
||||
fields: *trigger_common_fields
|
||||
|
||||
@@ -7,11 +7,9 @@
|
||||
required: true
|
||||
default: any
|
||||
selector:
|
||||
select:
|
||||
automation_behavior:
|
||||
translation_key: condition_behavior
|
||||
options:
|
||||
- all
|
||||
- any
|
||||
mode: condition
|
||||
|
||||
.number_or_entity: &number_or_entity
|
||||
required: false
|
||||
|
||||
@@ -7,12 +7,9 @@
|
||||
required: true
|
||||
default: any
|
||||
selector:
|
||||
select:
|
||||
automation_behavior:
|
||||
translation_key: trigger_behavior
|
||||
options:
|
||||
- first
|
||||
- last
|
||||
- any
|
||||
mode: trigger
|
||||
|
||||
started_drying: *trigger_common
|
||||
started_humidifying: *trigger_common
|
||||
|
||||
@@ -34,10 +34,8 @@ is_value:
|
||||
required: true
|
||||
default: any
|
||||
selector:
|
||||
select:
|
||||
automation_behavior:
|
||||
translation_key: condition_behavior
|
||||
options:
|
||||
- all
|
||||
- any
|
||||
mode: condition
|
||||
above: *number_or_entity
|
||||
below: *number_or_entity
|
||||
|
||||
@@ -3,12 +3,9 @@
|
||||
required: true
|
||||
default: any
|
||||
selector:
|
||||
select:
|
||||
automation_behavior:
|
||||
translation_key: trigger_behavior
|
||||
options:
|
||||
- first
|
||||
- last
|
||||
- any
|
||||
mode: trigger
|
||||
|
||||
.number_or_entity: &number_or_entity
|
||||
required: false
|
||||
|
||||
@@ -8,11 +8,9 @@
|
||||
required: true
|
||||
default: any
|
||||
selector:
|
||||
select:
|
||||
automation_behavior:
|
||||
translation_key: condition_behavior
|
||||
options:
|
||||
- all
|
||||
- any
|
||||
mode: condition
|
||||
|
||||
.number_or_entity: &number_or_entity
|
||||
required: false
|
||||
|
||||
@@ -3,12 +3,9 @@
|
||||
required: true
|
||||
default: any
|
||||
selector:
|
||||
select:
|
||||
automation_behavior:
|
||||
translation_key: trigger_behavior
|
||||
options:
|
||||
- first
|
||||
- last
|
||||
- any
|
||||
mode: trigger
|
||||
|
||||
.number_or_entity: &number_or_entity
|
||||
required: false
|
||||
|
||||
@@ -7,11 +7,9 @@
|
||||
required: true
|
||||
default: any
|
||||
selector:
|
||||
select:
|
||||
automation_behavior:
|
||||
translation_key: condition_behavior
|
||||
options:
|
||||
- all
|
||||
- any
|
||||
mode: condition
|
||||
|
||||
is_docked: *condition_common
|
||||
is_encountering_an_error: *condition_common
|
||||
|
||||
@@ -7,12 +7,9 @@
|
||||
required: true
|
||||
default: any
|
||||
selector:
|
||||
select:
|
||||
options:
|
||||
- first
|
||||
- last
|
||||
- any
|
||||
automation_behavior:
|
||||
translation_key: trigger_behavior
|
||||
mode: trigger
|
||||
|
||||
docked: *trigger_common
|
||||
errored: *trigger_common
|
||||
|
||||
@@ -7,11 +7,9 @@
|
||||
required: true
|
||||
default: any
|
||||
selector:
|
||||
select:
|
||||
automation_behavior:
|
||||
translation_key: condition_behavior
|
||||
options:
|
||||
- all
|
||||
- any
|
||||
mode: condition
|
||||
|
||||
is_off: *condition_common
|
||||
is_on: *condition_common
|
||||
|
||||
@@ -7,12 +7,9 @@
|
||||
required: true
|
||||
default: any
|
||||
selector:
|
||||
select:
|
||||
options:
|
||||
- first
|
||||
- last
|
||||
- any
|
||||
automation_behavior:
|
||||
translation_key: trigger_behavior
|
||||
mode: trigger
|
||||
|
||||
.number_or_entity: &number_or_entity
|
||||
required: false
|
||||
|
||||
@@ -7,11 +7,9 @@
|
||||
required: true
|
||||
default: any
|
||||
selector:
|
||||
select:
|
||||
automation_behavior:
|
||||
translation_key: condition_behavior
|
||||
options:
|
||||
- all
|
||||
- any
|
||||
mode: condition
|
||||
|
||||
is_jammed: *condition_common
|
||||
is_locked: *condition_common
|
||||
|
||||
@@ -7,12 +7,9 @@
|
||||
required: true
|
||||
default: any
|
||||
selector:
|
||||
select:
|
||||
options:
|
||||
- first
|
||||
- last
|
||||
- any
|
||||
automation_behavior:
|
||||
translation_key: trigger_behavior
|
||||
mode: trigger
|
||||
|
||||
jammed: *trigger_common
|
||||
locked: *trigger_common
|
||||
|
||||
@@ -7,11 +7,9 @@
|
||||
required: true
|
||||
default: any
|
||||
selector:
|
||||
select:
|
||||
automation_behavior:
|
||||
translation_key: condition_behavior
|
||||
options:
|
||||
- all
|
||||
- any
|
||||
mode: condition
|
||||
|
||||
is_off: *condition_common
|
||||
is_on: *condition_common
|
||||
|
||||
@@ -7,9 +7,6 @@ stopped_playing:
|
||||
required: true
|
||||
default: any
|
||||
selector:
|
||||
select:
|
||||
automation_behavior:
|
||||
translation_key: trigger_behavior
|
||||
options:
|
||||
- first
|
||||
- last
|
||||
- any
|
||||
mode: trigger
|
||||
|
||||
@@ -3,12 +3,9 @@
|
||||
required: true
|
||||
default: any
|
||||
selector:
|
||||
select:
|
||||
automation_behavior:
|
||||
translation_key: trigger_behavior
|
||||
options:
|
||||
- first
|
||||
- last
|
||||
- any
|
||||
mode: trigger
|
||||
|
||||
.number_or_entity: &number_or_entity
|
||||
required: false
|
||||
|
||||
@@ -3,11 +3,9 @@
|
||||
required: true
|
||||
default: any
|
||||
selector:
|
||||
select:
|
||||
automation_behavior:
|
||||
translation_key: condition_behavior
|
||||
options:
|
||||
- all
|
||||
- any
|
||||
mode: condition
|
||||
|
||||
is_detected:
|
||||
fields: *condition_common_fields
|
||||
|
||||
@@ -3,12 +3,9 @@
|
||||
required: true
|
||||
default: any
|
||||
selector:
|
||||
select:
|
||||
automation_behavior:
|
||||
translation_key: trigger_behavior
|
||||
options:
|
||||
- first
|
||||
- last
|
||||
- any
|
||||
mode: trigger
|
||||
|
||||
detected:
|
||||
fields: *trigger_common_fields
|
||||
|
||||
@@ -3,11 +3,9 @@
|
||||
required: true
|
||||
default: any
|
||||
selector:
|
||||
select:
|
||||
automation_behavior:
|
||||
translation_key: condition_behavior
|
||||
options:
|
||||
- all
|
||||
- any
|
||||
mode: condition
|
||||
|
||||
is_detected:
|
||||
fields: *condition_common_fields
|
||||
|
||||
@@ -3,12 +3,9 @@
|
||||
required: true
|
||||
default: any
|
||||
selector:
|
||||
select:
|
||||
automation_behavior:
|
||||
translation_key: trigger_behavior
|
||||
options:
|
||||
- first
|
||||
- last
|
||||
- any
|
||||
mode: trigger
|
||||
|
||||
detected:
|
||||
fields: *trigger_common_fields
|
||||
|
||||
@@ -7,11 +7,9 @@
|
||||
required: true
|
||||
default: any
|
||||
selector:
|
||||
select:
|
||||
automation_behavior:
|
||||
translation_key: condition_behavior
|
||||
options:
|
||||
- all
|
||||
- any
|
||||
mode: condition
|
||||
|
||||
is_home: *condition_common
|
||||
is_not_home: *condition_common
|
||||
|
||||
@@ -7,12 +7,9 @@
|
||||
required: true
|
||||
default: any
|
||||
selector:
|
||||
select:
|
||||
options:
|
||||
- first
|
||||
- last
|
||||
- any
|
||||
automation_behavior:
|
||||
translation_key: trigger_behavior
|
||||
mode: trigger
|
||||
|
||||
entered_home: *trigger_common
|
||||
left_home: *trigger_common
|
||||
|
||||
@@ -51,11 +51,9 @@ is_value:
|
||||
required: true
|
||||
default: any
|
||||
selector:
|
||||
select:
|
||||
automation_behavior:
|
||||
translation_key: condition_behavior
|
||||
options:
|
||||
- all
|
||||
- any
|
||||
mode: condition
|
||||
above: *number_or_entity_power
|
||||
below: *number_or_entity_power
|
||||
unit: *condition_unit_power
|
||||
|
||||
@@ -3,12 +3,9 @@
|
||||
required: true
|
||||
default: any
|
||||
selector:
|
||||
select:
|
||||
automation_behavior:
|
||||
translation_key: trigger_behavior
|
||||
options:
|
||||
- first
|
||||
- last
|
||||
- any
|
||||
mode: trigger
|
||||
|
||||
.number_or_entity: &number_or_entity
|
||||
required: false
|
||||
|
||||
@@ -7,12 +7,9 @@
|
||||
required: true
|
||||
default: any
|
||||
selector:
|
||||
select:
|
||||
options:
|
||||
- first
|
||||
- last
|
||||
- any
|
||||
automation_behavior:
|
||||
translation_key: trigger_behavior
|
||||
mode: trigger
|
||||
|
||||
turned_off: *trigger_common
|
||||
turned_on: *trigger_common
|
||||
|
||||
@@ -7,11 +7,9 @@
|
||||
required: true
|
||||
default: any
|
||||
selector:
|
||||
select:
|
||||
automation_behavior:
|
||||
translation_key: condition_behavior
|
||||
options:
|
||||
- all
|
||||
- any
|
||||
mode: condition
|
||||
|
||||
is_off: *condition_common
|
||||
is_on: *condition_common
|
||||
|
||||
@@ -7,12 +7,9 @@
|
||||
required: true
|
||||
default: any
|
||||
selector:
|
||||
select:
|
||||
options:
|
||||
- first
|
||||
- last
|
||||
- any
|
||||
automation_behavior:
|
||||
translation_key: trigger_behavior
|
||||
mode: trigger
|
||||
|
||||
turned_off: *trigger_common
|
||||
turned_on: *trigger_common
|
||||
|
||||
@@ -7,11 +7,9 @@
|
||||
required: true
|
||||
default: any
|
||||
selector:
|
||||
select:
|
||||
automation_behavior:
|
||||
translation_key: condition_behavior
|
||||
options:
|
||||
- all
|
||||
- any
|
||||
mode: condition
|
||||
|
||||
is_off: *condition_common
|
||||
is_on: *condition_common
|
||||
|
||||
@@ -7,12 +7,9 @@
|
||||
required: true
|
||||
default: any
|
||||
selector:
|
||||
select:
|
||||
options:
|
||||
- first
|
||||
- last
|
||||
- any
|
||||
automation_behavior:
|
||||
translation_key: trigger_behavior
|
||||
mode: trigger
|
||||
|
||||
turned_off: *trigger_common
|
||||
turned_on: *trigger_common
|
||||
|
||||
@@ -7,11 +7,9 @@
|
||||
required: true
|
||||
default: any
|
||||
selector:
|
||||
select:
|
||||
automation_behavior:
|
||||
translation_key: condition_behavior
|
||||
options:
|
||||
- all
|
||||
- any
|
||||
mode: condition
|
||||
|
||||
is_off: *condition_common
|
||||
is_on: *condition_common
|
||||
|
||||
@@ -8,12 +8,9 @@
|
||||
required: true
|
||||
default: any
|
||||
selector:
|
||||
select:
|
||||
options:
|
||||
- first
|
||||
- last
|
||||
- any
|
||||
automation_behavior:
|
||||
translation_key: trigger_behavior
|
||||
mode: trigger
|
||||
|
||||
turned_off: *trigger_common
|
||||
turned_on: *trigger_common
|
||||
|
||||
@@ -3,12 +3,9 @@
|
||||
required: true
|
||||
default: any
|
||||
selector:
|
||||
select:
|
||||
automation_behavior:
|
||||
translation_key: trigger_behavior
|
||||
options:
|
||||
- first
|
||||
- last
|
||||
- any
|
||||
mode: trigger
|
||||
|
||||
.number_or_entity: &number_or_entity
|
||||
required: false
|
||||
|
||||
@@ -8,11 +8,9 @@ is_equal_to:
|
||||
required: true
|
||||
default: any
|
||||
selector:
|
||||
select:
|
||||
automation_behavior:
|
||||
translation_key: condition_behavior
|
||||
options:
|
||||
- all
|
||||
- any
|
||||
mode: condition
|
||||
value:
|
||||
required: true
|
||||
selector:
|
||||
|
||||
@@ -7,11 +7,8 @@
|
||||
required: true
|
||||
default: any
|
||||
selector:
|
||||
select:
|
||||
options:
|
||||
- first
|
||||
- last
|
||||
- any
|
||||
automation_behavior:
|
||||
translation_key: trigger_behavior
|
||||
mode: trigger
|
||||
|
||||
update_became_available: *trigger_common
|
||||
|
||||
@@ -7,11 +7,9 @@
|
||||
required: true
|
||||
default: any
|
||||
selector:
|
||||
select:
|
||||
automation_behavior:
|
||||
translation_key: condition_behavior
|
||||
options:
|
||||
- all
|
||||
- any
|
||||
mode: condition
|
||||
|
||||
is_cleaning: *condition_common
|
||||
is_docked: *condition_common
|
||||
|
||||
@@ -7,12 +7,9 @@
|
||||
required: true
|
||||
default: any
|
||||
selector:
|
||||
select:
|
||||
options:
|
||||
- first
|
||||
- last
|
||||
- any
|
||||
automation_behavior:
|
||||
translation_key: trigger_behavior
|
||||
mode: trigger
|
||||
|
||||
docked: *trigger_common
|
||||
errored: *trigger_common
|
||||
|
||||
@@ -7,11 +7,9 @@
|
||||
required: true
|
||||
default: any
|
||||
selector:
|
||||
select:
|
||||
automation_behavior:
|
||||
translation_key: condition_behavior
|
||||
options:
|
||||
- all
|
||||
- any
|
||||
mode: condition
|
||||
|
||||
.number_or_entity_temperature: &number_or_entity_temperature
|
||||
required: false
|
||||
|
||||
@@ -7,12 +7,9 @@
|
||||
required: true
|
||||
default: any
|
||||
selector:
|
||||
select:
|
||||
automation_behavior:
|
||||
translation_key: trigger_behavior
|
||||
options:
|
||||
- first
|
||||
- last
|
||||
- any
|
||||
mode: trigger
|
||||
|
||||
.trigger_threshold_type: &trigger_threshold_type
|
||||
required: true
|
||||
|
||||
@@ -3,11 +3,9 @@
|
||||
required: true
|
||||
default: any
|
||||
selector:
|
||||
select:
|
||||
automation_behavior:
|
||||
translation_key: condition_behavior
|
||||
options:
|
||||
- all
|
||||
- any
|
||||
mode: condition
|
||||
|
||||
is_closed:
|
||||
fields: *condition_common_fields
|
||||
|
||||
@@ -3,12 +3,9 @@
|
||||
required: true
|
||||
default: any
|
||||
selector:
|
||||
select:
|
||||
automation_behavior:
|
||||
translation_key: trigger_behavior
|
||||
options:
|
||||
- first
|
||||
- last
|
||||
- any
|
||||
mode: trigger
|
||||
|
||||
closed:
|
||||
fields: *trigger_common_fields
|
||||
|
||||
@@ -243,6 +243,69 @@ class DeviceFilterSelectorConfig(TypedDict, total=False):
|
||||
model_id: str
|
||||
|
||||
|
||||
class AutomationBehavior(StrEnum):
|
||||
"""Possible behaviors for an automation behavior selector."""
|
||||
|
||||
ALL = "all"
|
||||
FIRST = "first"
|
||||
LAST = "last"
|
||||
ANY = "any"
|
||||
|
||||
|
||||
class AutomationBehaviorSelectorMode(StrEnum):
|
||||
"""Possible modes for an automation behavior selector."""
|
||||
|
||||
TRIGGER = "trigger"
|
||||
CONDITION = "condition"
|
||||
|
||||
|
||||
_AUTOMATION_BEHAVIOR_MODES: dict[AutomationBehaviorSelectorMode, list[str]] = {
|
||||
AutomationBehaviorSelectorMode.TRIGGER: [
|
||||
AutomationBehavior.FIRST,
|
||||
AutomationBehavior.LAST,
|
||||
AutomationBehavior.ANY,
|
||||
],
|
||||
AutomationBehaviorSelectorMode.CONDITION: [
|
||||
AutomationBehavior.ALL,
|
||||
AutomationBehavior.ANY,
|
||||
],
|
||||
}
|
||||
|
||||
|
||||
class AutomationBehaviorConfig(BaseSelectorConfig, total=False):
|
||||
"""Class to represent an automation behavior selector config."""
|
||||
|
||||
mode: Required[AutomationBehaviorSelectorMode]
|
||||
translation_key: str
|
||||
|
||||
|
||||
@SELECTORS.register("automation_behavior")
|
||||
class AutomationBehaviorSelector(Selector[AutomationBehaviorConfig]):
|
||||
"""Selector of an automation behavior."""
|
||||
|
||||
selector_type = "automation_behavior"
|
||||
|
||||
CONFIG_SCHEMA = make_selector_config_schema(
|
||||
{
|
||||
vol.Required("mode"): vol.All(
|
||||
vol.Coerce(AutomationBehaviorSelectorMode), lambda val: val.value
|
||||
),
|
||||
vol.Optional("translation_key"): cv.string,
|
||||
},
|
||||
)
|
||||
|
||||
def __init__(self, config: AutomationBehaviorConfig | None = None) -> None:
|
||||
"""Instantiate a selector."""
|
||||
super().__init__(config)
|
||||
|
||||
def __call__(self, data: Any) -> Any:
|
||||
"""Validate the passed selection."""
|
||||
if not isinstance(data, str):
|
||||
raise vol.Invalid("Value should be a string")
|
||||
mode = AutomationBehaviorSelectorMode(self.config["mode"])
|
||||
return vol.In(_AUTOMATION_BEHAVIOR_MODES[mode])(data)
|
||||
|
||||
|
||||
class ActionSelectorConfig(BaseSelectorConfig):
|
||||
"""Class to represent an action selector config."""
|
||||
|
||||
|
||||
@@ -1183,6 +1183,46 @@ def test_action_selector_schema(schema, valid_selections, invalid_selections) ->
|
||||
_test_selector("action", schema, valid_selections, invalid_selections)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("schema", "valid_selections", "invalid_selections"),
|
||||
[
|
||||
(
|
||||
{"mode": "trigger"},
|
||||
("first", "last", "any"),
|
||||
("all", "invalid", None),
|
||||
),
|
||||
(
|
||||
{"mode": "condition"},
|
||||
("all", "any"),
|
||||
("first", "last", "invalid", None),
|
||||
),
|
||||
(
|
||||
{"mode": "trigger", "translation_key": "trigger_behavior"},
|
||||
("first", "last", "any"),
|
||||
("all", "invalid", None),
|
||||
),
|
||||
],
|
||||
)
|
||||
def test_automation_behavior_selector_schema(
|
||||
schema, valid_selections, invalid_selections
|
||||
) -> None:
|
||||
"""Test automation behavior selector."""
|
||||
_test_selector("automation_behavior", schema, valid_selections, invalid_selections)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"schema",
|
||||
[
|
||||
{},
|
||||
{"mode": "invalid_mode"},
|
||||
],
|
||||
)
|
||||
def test_automation_behavior_selector_schema_error(schema) -> None:
|
||||
"""Test automation behavior selector config schema errors."""
|
||||
with pytest.raises(vol.Invalid):
|
||||
selector.validate_selector({"automation_behavior": schema})
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("schema", "valid_selections", "invalid_selections"),
|
||||
[
|
||||
|
||||
Reference in New Issue
Block a user