Services (small_pr)(fix): Added missing return on data template error (#12184)
* Added return on data template error * Rebased so not sure why spelling errors returned...
This commit is contained in:
parent
137933a774
commit
f5030d9ebf
2 changed files with 19 additions and 0 deletions
|
@ -74,6 +74,7 @@ def async_call_from_config(hass, config, blocking=False, variables=None,
|
||||||
config[CONF_SERVICE_DATA_TEMPLATE], variables))
|
config[CONF_SERVICE_DATA_TEMPLATE], variables))
|
||||||
except TemplateError as ex:
|
except TemplateError as ex:
|
||||||
_LOGGER.error('Error rendering data template: %s', ex)
|
_LOGGER.error('Error rendering data template: %s', ex)
|
||||||
|
return
|
||||||
|
|
||||||
if CONF_SERVICE_ENTITY_ID in config:
|
if CONF_SERVICE_ENTITY_ID in config:
|
||||||
service_data[ATTR_ENTITY_ID] = config[CONF_SERVICE_ENTITY_ID]
|
service_data[ATTR_ENTITY_ID] = config[CONF_SERVICE_ENTITY_ID]
|
||||||
|
|
|
@ -68,6 +68,24 @@ class TestServiceHelpers(unittest.TestCase):
|
||||||
|
|
||||||
self.assertEqual('goodbye', self.calls[0].data['hello'])
|
self.assertEqual('goodbye', self.calls[0].data['hello'])
|
||||||
|
|
||||||
|
def test_bad_template(self):
|
||||||
|
"""Test passing bad template."""
|
||||||
|
config = {
|
||||||
|
'service_template': '{{ var_service }}',
|
||||||
|
'entity_id': 'hello.world',
|
||||||
|
'data_template': {
|
||||||
|
'hello': '{{ states + unknown_var }}'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
service.call_from_config(self.hass, config, variables={
|
||||||
|
'var_service': 'test_domain.test_service',
|
||||||
|
'var_data': 'goodbye',
|
||||||
|
})
|
||||||
|
self.hass.block_till_done()
|
||||||
|
|
||||||
|
self.assertEqual(len(self.calls), 0)
|
||||||
|
|
||||||
def test_split_entity_string(self):
|
def test_split_entity_string(self):
|
||||||
"""Test splitting of entity string."""
|
"""Test splitting of entity string."""
|
||||||
service.call_from_config(self.hass, {
|
service.call_from_config(self.hass, {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue