Fix translation, adjust trigger names (#26635)

This commit is contained in:
Erik Montnemery 2019-09-17 21:55:01 +02:00 committed by Bram Kragten
parent 4a30c1023c
commit bc7ff8323c
7 changed files with 24 additions and 20 deletions

View File

@ -4,3 +4,5 @@ CONF_IS_ON = "is_on"
CONF_TOGGLE = "toggle" CONF_TOGGLE = "toggle"
CONF_TURN_OFF = "turn_off" CONF_TURN_OFF = "turn_off"
CONF_TURN_ON = "turn_on" CONF_TURN_ON = "turn_on"
CONF_TURNED_OFF = "turned_off"
CONF_TURNED_ON = "turned_on"

View File

@ -8,6 +8,8 @@ from homeassistant.components.device_automation.const import (
CONF_TOGGLE, CONF_TOGGLE,
CONF_TURN_OFF, CONF_TURN_OFF,
CONF_TURN_ON, CONF_TURN_ON,
CONF_TURNED_OFF,
CONF_TURNED_ON,
) )
from homeassistant.core import split_entity_id from homeassistant.core import split_entity_id
from homeassistant.const import ( from homeassistant.const import (
@ -53,12 +55,12 @@ ENTITY_TRIGGERS = [
{ {
# Trigger when entity is turned off # Trigger when entity is turned off
CONF_PLATFORM: "device", CONF_PLATFORM: "device",
CONF_TYPE: CONF_TURN_OFF, CONF_TYPE: CONF_TURNED_OFF,
}, },
{ {
# Trigger when entity is turned on # Trigger when entity is turned on
CONF_PLATFORM: "device", 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_DEVICE_ID): str,
vol.Required(CONF_DOMAIN): str, vol.Required(CONF_DOMAIN): str,
vol.Required(CONF_ENTITY_ID): cv.entity_id, 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): async def async_attach_trigger(hass, config, action, automation_info):
"""Listen for state changes based on configuration.""" """Listen for state changes based on configuration."""
trigger_type = config[CONF_TYPE] trigger_type = config[CONF_TYPE]
if trigger_type == CONF_TURN_ON: if trigger_type == CONF_TURNED_ON:
from_state = "off" from_state = "off"
to_state = "on" to_state = "on"
else: else:

View File

@ -10,8 +10,8 @@
"is_off": "{entity_name} is off" "is_off": "{entity_name} is off"
}, },
"trigger_type": { "trigger_type": {
"turn_on": "{entity_name} turned on", "turned_on": "{entity_name} turned on",
"turn_off": "{entity_name} turned off" "turned_off": "{entity_name} turned off"
} }
} }
} }

View File

@ -6,12 +6,12 @@
"turn_off": "Turn off {entity_name}" "turn_off": "Turn off {entity_name}"
}, },
"condition_type": { "condition_type": {
"turn_on": "{entity_name} turned on", "is_on": "{entity_name} is on",
"turn_off": "{entity_name} turned off" "is_off": "{entity_name} is off"
}, },
"trigger_type": { "trigger_type": {
"turn_on": "{entity_name} turned on", "turned_on": "{entity_name} turned on",
"turn_off": "{entity_name} turned off" "turned_off": "{entity_name} turned off"
} }
} }
} }

View File

@ -133,14 +133,14 @@ async def test_websocket_get_triggers(hass, hass_ws_client, device_reg, entity_r
{ {
"platform": "device", "platform": "device",
"domain": "light", "domain": "light",
"type": "turn_off", "type": "turned_off",
"device_id": device_entry.id, "device_id": device_entry.id,
"entity_id": "light.test_5678", "entity_id": "light.test_5678",
}, },
{ {
"platform": "device", "platform": "device",
"domain": "light", "domain": "light",
"type": "turn_on", "type": "turned_on",
"device_id": device_entry.id, "device_id": device_entry.id,
"entity_id": "light.test_5678", "entity_id": "light.test_5678",
}, },

View File

@ -125,14 +125,14 @@ async def test_get_triggers(hass, device_reg, entity_reg):
{ {
"platform": "device", "platform": "device",
"domain": DOMAIN, "domain": DOMAIN,
"type": "turn_off", "type": "turned_off",
"device_id": device_entry.id, "device_id": device_entry.id,
"entity_id": f"{DOMAIN}.test_5678", "entity_id": f"{DOMAIN}.test_5678",
}, },
{ {
"platform": "device", "platform": "device",
"domain": DOMAIN, "domain": DOMAIN,
"type": "turn_on", "type": "turned_on",
"device_id": device_entry.id, "device_id": device_entry.id,
"entity_id": f"{DOMAIN}.test_5678", "entity_id": f"{DOMAIN}.test_5678",
}, },
@ -163,7 +163,7 @@ async def test_if_fires_on_state_change(hass, calls):
"domain": DOMAIN, "domain": DOMAIN,
"device_id": "", "device_id": "",
"entity_id": ent1.entity_id, "entity_id": ent1.entity_id,
"type": "turn_on", "type": "turned_on",
}, },
"action": { "action": {
"service": "test.automation", "service": "test.automation",
@ -187,7 +187,7 @@ async def test_if_fires_on_state_change(hass, calls):
"domain": DOMAIN, "domain": DOMAIN,
"device_id": "", "device_id": "",
"entity_id": ent1.entity_id, "entity_id": ent1.entity_id,
"type": "turn_off", "type": "turned_off",
}, },
"action": { "action": {
"service": "test.automation", "service": "test.automation",

View File

@ -125,14 +125,14 @@ async def test_get_triggers(hass, device_reg, entity_reg):
{ {
"platform": "device", "platform": "device",
"domain": DOMAIN, "domain": DOMAIN,
"type": "turn_off", "type": "turned_off",
"device_id": device_entry.id, "device_id": device_entry.id,
"entity_id": f"{DOMAIN}.test_5678", "entity_id": f"{DOMAIN}.test_5678",
}, },
{ {
"platform": "device", "platform": "device",
"domain": DOMAIN, "domain": DOMAIN,
"type": "turn_on", "type": "turned_on",
"device_id": device_entry.id, "device_id": device_entry.id,
"entity_id": f"{DOMAIN}.test_5678", "entity_id": f"{DOMAIN}.test_5678",
}, },
@ -163,7 +163,7 @@ async def test_if_fires_on_state_change(hass, calls):
"domain": DOMAIN, "domain": DOMAIN,
"device_id": "", "device_id": "",
"entity_id": ent1.entity_id, "entity_id": ent1.entity_id,
"type": "turn_on", "type": "turned_on",
}, },
"action": { "action": {
"service": "test.automation", "service": "test.automation",
@ -187,7 +187,7 @@ async def test_if_fires_on_state_change(hass, calls):
"domain": DOMAIN, "domain": DOMAIN,
"device_id": "", "device_id": "",
"entity_id": ent1.entity_id, "entity_id": ent1.entity_id,
"type": "turn_off", "type": "turned_off",
}, },
"action": { "action": {
"service": "test.automation", "service": "test.automation",