Fix translation, adjust trigger names (#26635)
This commit is contained in:
parent
10572a62b1
commit
504b8c7685
7 changed files with 24 additions and 20 deletions
|
@ -4,3 +4,5 @@ CONF_IS_ON = "is_on"
|
|||
CONF_TOGGLE = "toggle"
|
||||
CONF_TURN_OFF = "turn_off"
|
||||
CONF_TURN_ON = "turn_on"
|
||||
CONF_TURNED_OFF = "turned_off"
|
||||
CONF_TURNED_ON = "turned_on"
|
||||
|
|
|
@ -8,6 +8,8 @@ from homeassistant.components.device_automation.const import (
|
|||
CONF_TOGGLE,
|
||||
CONF_TURN_OFF,
|
||||
CONF_TURN_ON,
|
||||
CONF_TURNED_OFF,
|
||||
CONF_TURNED_ON,
|
||||
)
|
||||
from homeassistant.core import split_entity_id
|
||||
from homeassistant.const import (
|
||||
|
@ -53,12 +55,12 @@ ENTITY_TRIGGERS = [
|
|||
{
|
||||
# Trigger when entity is turned off
|
||||
CONF_PLATFORM: "device",
|
||||
CONF_TYPE: CONF_TURN_OFF,
|
||||
CONF_TYPE: CONF_TURNED_OFF,
|
||||
},
|
||||
{
|
||||
# Trigger when entity is turned on
|
||||
CONF_PLATFORM: "device",
|
||||
CONF_TYPE: CONF_TURN_ON,
|
||||
CONF_TYPE: CONF_TURNED_ON,
|
||||
},
|
||||
]
|
||||
|
||||
|
@ -87,7 +89,7 @@ TRIGGER_SCHEMA = vol.Schema(
|
|||
vol.Required(CONF_DEVICE_ID): str,
|
||||
vol.Required(CONF_DOMAIN): str,
|
||||
vol.Required(CONF_ENTITY_ID): cv.entity_id,
|
||||
vol.Required(CONF_TYPE): vol.In([CONF_TURN_OFF, CONF_TURN_ON]),
|
||||
vol.Required(CONF_TYPE): vol.In([CONF_TURNED_OFF, CONF_TURNED_ON]),
|
||||
}
|
||||
)
|
||||
|
||||
|
@ -136,7 +138,7 @@ def async_condition_from_config(config, config_validation):
|
|||
async def async_attach_trigger(hass, config, action, automation_info):
|
||||
"""Listen for state changes based on configuration."""
|
||||
trigger_type = config[CONF_TYPE]
|
||||
if trigger_type == CONF_TURN_ON:
|
||||
if trigger_type == CONF_TURNED_ON:
|
||||
from_state = "off"
|
||||
to_state = "on"
|
||||
else:
|
||||
|
|
|
@ -10,8 +10,8 @@
|
|||
"is_off": "{entity_name} is off"
|
||||
},
|
||||
"trigger_type": {
|
||||
"turn_on": "{entity_name} turned on",
|
||||
"turn_off": "{entity_name} turned off"
|
||||
"turned_on": "{entity_name} turned on",
|
||||
"turned_off": "{entity_name} turned off"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,12 +6,12 @@
|
|||
"turn_off": "Turn off {entity_name}"
|
||||
},
|
||||
"condition_type": {
|
||||
"turn_on": "{entity_name} turned on",
|
||||
"turn_off": "{entity_name} turned off"
|
||||
"is_on": "{entity_name} is on",
|
||||
"is_off": "{entity_name} is off"
|
||||
},
|
||||
"trigger_type": {
|
||||
"turn_on": "{entity_name} turned on",
|
||||
"turn_off": "{entity_name} turned off"
|
||||
"turned_on": "{entity_name} turned on",
|
||||
"turned_off": "{entity_name} turned off"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -133,14 +133,14 @@ async def test_websocket_get_triggers(hass, hass_ws_client, device_reg, entity_r
|
|||
{
|
||||
"platform": "device",
|
||||
"domain": "light",
|
||||
"type": "turn_off",
|
||||
"type": "turned_off",
|
||||
"device_id": device_entry.id,
|
||||
"entity_id": "light.test_5678",
|
||||
},
|
||||
{
|
||||
"platform": "device",
|
||||
"domain": "light",
|
||||
"type": "turn_on",
|
||||
"type": "turned_on",
|
||||
"device_id": device_entry.id,
|
||||
"entity_id": "light.test_5678",
|
||||
},
|
||||
|
|
|
@ -125,14 +125,14 @@ async def test_get_triggers(hass, device_reg, entity_reg):
|
|||
{
|
||||
"platform": "device",
|
||||
"domain": DOMAIN,
|
||||
"type": "turn_off",
|
||||
"type": "turned_off",
|
||||
"device_id": device_entry.id,
|
||||
"entity_id": f"{DOMAIN}.test_5678",
|
||||
},
|
||||
{
|
||||
"platform": "device",
|
||||
"domain": DOMAIN,
|
||||
"type": "turn_on",
|
||||
"type": "turned_on",
|
||||
"device_id": device_entry.id,
|
||||
"entity_id": f"{DOMAIN}.test_5678",
|
||||
},
|
||||
|
@ -163,7 +163,7 @@ async def test_if_fires_on_state_change(hass, calls):
|
|||
"domain": DOMAIN,
|
||||
"device_id": "",
|
||||
"entity_id": ent1.entity_id,
|
||||
"type": "turn_on",
|
||||
"type": "turned_on",
|
||||
},
|
||||
"action": {
|
||||
"service": "test.automation",
|
||||
|
@ -187,7 +187,7 @@ async def test_if_fires_on_state_change(hass, calls):
|
|||
"domain": DOMAIN,
|
||||
"device_id": "",
|
||||
"entity_id": ent1.entity_id,
|
||||
"type": "turn_off",
|
||||
"type": "turned_off",
|
||||
},
|
||||
"action": {
|
||||
"service": "test.automation",
|
||||
|
|
|
@ -125,14 +125,14 @@ async def test_get_triggers(hass, device_reg, entity_reg):
|
|||
{
|
||||
"platform": "device",
|
||||
"domain": DOMAIN,
|
||||
"type": "turn_off",
|
||||
"type": "turned_off",
|
||||
"device_id": device_entry.id,
|
||||
"entity_id": f"{DOMAIN}.test_5678",
|
||||
},
|
||||
{
|
||||
"platform": "device",
|
||||
"domain": DOMAIN,
|
||||
"type": "turn_on",
|
||||
"type": "turned_on",
|
||||
"device_id": device_entry.id,
|
||||
"entity_id": f"{DOMAIN}.test_5678",
|
||||
},
|
||||
|
@ -163,7 +163,7 @@ async def test_if_fires_on_state_change(hass, calls):
|
|||
"domain": DOMAIN,
|
||||
"device_id": "",
|
||||
"entity_id": ent1.entity_id,
|
||||
"type": "turn_on",
|
||||
"type": "turned_on",
|
||||
},
|
||||
"action": {
|
||||
"service": "test.automation",
|
||||
|
@ -187,7 +187,7 @@ async def test_if_fires_on_state_change(hass, calls):
|
|||
"domain": DOMAIN,
|
||||
"device_id": "",
|
||||
"entity_id": ent1.entity_id,
|
||||
"type": "turn_off",
|
||||
"type": "turned_off",
|
||||
},
|
||||
"action": {
|
||||
"service": "test.automation",
|
||||
|
|
Loading…
Add table
Reference in a new issue