Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions homeassistant/helpers/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from homeassistant.const import (
ATTR_LATITUDE, ATTR_LONGITUDE, ATTR_UNIT_OF_MEASUREMENT, MATCH_ALL,
STATE_UNKNOWN)
from homeassistant.core import State
from homeassistant.core import State, valid_entity_id
from homeassistant.exceptions import TemplateError
from homeassistant.helpers import location as loc_helper
from homeassistant.loader import bind_hass, get_component
Expand Down Expand Up @@ -73,7 +73,8 @@ def extract_entities(template, variables=None):
extraction_final.append(result[0])

if variables and result[1] in variables and \
isinstance(variables[result[1]], str):
isinstance(variables[result[1]], str) and \
valid_entity_id(variables[result[1]]):
extraction_final.append(variables[result[1]])

if extraction_final:
Expand Down
6 changes: 6 additions & 0 deletions tests/helpers/test_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -836,6 +836,12 @@ def test_extract_entities_with_variables(self):
"{{ is_state(trigger.entity_id, 'off') }}",
{'trigger': {'entity_id': 'input_boolean.switch'}}))

self.assertEqual(
MATCH_ALL,
template.extract_entities(
"{{ is_state('media_player.' ~ where , 'playing') }}",
{'where': 'livingroom'}))


@asyncio.coroutine
def test_state_with_unit(hass):
Expand Down