Skip to content

Commit

Permalink
Add missing constants trigger_typeand condition_type (#93415)
Browse files Browse the repository at this point in the history
* Add missing `trigger_type`and  ´condition_type`

* auto generate `TURNED_ON` and  `TURNED_OFF`
  • Loading branch information
Ludy87 committed May 24, 2023
1 parent a29adc0 commit 3c7e6bf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 56 deletions.
59 changes: 3 additions & 56 deletions homeassistant/components/binary_sensor/device_trigger.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,62 +70,6 @@
CONF_NOT_OPENED = "not_opened"


TURNED_ON = [
CONF_BAT_LOW,
CONF_CO,
CONF_COLD,
CONF_CONNECTED,
CONF_GAS,
CONF_HOT,
CONF_LIGHT,
CONF_NOT_LOCKED,
CONF_MOIST,
CONF_MOTION,
CONF_MOVING,
CONF_OCCUPIED,
CONF_OPENED,
CONF_PLUGGED_IN,
CONF_POWERED,
CONF_PRESENT,
CONF_PROBLEM,
CONF_RUNNING,
CONF_SMOKE,
CONF_SOUND,
CONF_UNSAFE,
CONF_UPDATE,
CONF_VIBRATION,
CONF_TAMPERED,
CONF_TURNED_ON,
]

TURNED_OFF = [
CONF_NOT_BAT_LOW,
CONF_NOT_COLD,
CONF_NOT_CONNECTED,
CONF_NOT_HOT,
CONF_LOCKED,
CONF_NOT_MOIST,
CONF_NOT_MOVING,
CONF_NOT_OCCUPIED,
CONF_NOT_OPENED,
CONF_NOT_PLUGGED_IN,
CONF_NOT_POWERED,
CONF_NOT_PRESENT,
CONF_NOT_TAMPERED,
CONF_NOT_UNSAFE,
CONF_NO_CO,
CONF_NO_GAS,
CONF_NO_LIGHT,
CONF_NO_MOTION,
CONF_NO_PROBLEM,
CONF_NOT_RUNNING,
CONF_NO_SMOKE,
CONF_NO_SOUND,
CONF_NO_VIBRATION,
CONF_TURNED_OFF,
]


ENTITY_TRIGGERS = {
BinarySensorDeviceClass.BATTERY: [
{CONF_TYPE: CONF_BAT_LOW},
Expand Down Expand Up @@ -245,6 +189,9 @@
],
}

TURNED_ON = [trigger[0][CONF_TYPE] for trigger in ENTITY_TRIGGERS.values()]
TURNED_OFF = [trigger[1][CONF_TYPE] for trigger in ENTITY_TRIGGERS.values()]


TRIGGER_SCHEMA = DEVICE_TRIGGER_BASE_SCHEMA.extend(
{
Expand Down
4 changes: 4 additions & 0 deletions homeassistant/components/binary_sensor/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
"condition_type": {
"is_bat_low": "{entity_name} battery is low",
"is_not_bat_low": "{entity_name} battery is normal",
"is_charging": "{entity_name} is charging",
"is_not_charging": "{entity_name} is not charging",
"is_co": "{entity_name} is detecting carbon monoxide",
"is_no_co": "{entity_name} is not detecting carbon monoxide",
"is_cold": "{entity_name} is cold",
Expand Down Expand Up @@ -56,6 +58,8 @@
"trigger_type": {
"bat_low": "{entity_name} battery low",
"not_bat_low": "{entity_name} battery normal",
"charging": "{entity_name} charging",
"not_charging": "{entity_name} not charging",
"co": "{entity_name} started detecting carbon monoxide",
"no_co": "{entity_name} stopped detecting carbon monoxide",
"cold": "{entity_name} became cold",
Expand Down

0 comments on commit 3c7e6bf

Please sign in to comment.