Optimize template 2 (#3521)

* Enforce compiling templates

* Refactor templates

* Add template validator to Logbook service

* Some more fixes

* Lint

* Allow easy skipping of rfxtrx tests

* Fix template bug in AND & OR conditions

* add entities extractor

Conflicts:
	tests/helpers/test_template.py

* fix unittest

* Convert template to be async

* Fix Farcy

* Lint fix

* Limit template updates to related entities

* Make template automation async
This commit is contained in:
Paulus Schoutsen authored and GitHub committed 2016-09-27 21:29:55 -07:00
1 parent 6694b0470e
commit 00e298206e
52 files changed
+841 -562

No files matched your search

+3 -1
View File
@@ -1,6 +1,7 @@
"""The tests for the Command line sensor platform."""
import unittest
from homeassistant.helpers.template import Template
from homeassistant.components.sensor import command_line
from homeassistant import bootstrap
from tests.common import get_test_home_assistant
@@ -53,7 +54,8 @@ class TestCommandSensorSensor(unittest.TestCase):
data = command_line.CommandSensorData('echo 50')
entity = command_line.CommandSensor(
self.hass, data, 'test', 'in', '{{ value | multiply(0.1) }}')
self.hass, data, 'test', 'in',
Template('{{ value | multiply(0.1) }}', self.hass))
self.assertEqual(5, float(entity.state))
@@ -1,16 +1,16 @@
"""The tests for the IMAP email content sensor platform."""
import unittest
from collections import deque
import email
import datetime
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
import datetime
from threading import Event
import unittest
from homeassistant.helpers.template import Template
from homeassistant.helpers.event import track_state_change
from collections import deque
from homeassistant.components.sensor import imap_email_content
from tests.common import get_test_home_assistant
@@ -218,7 +218,8 @@ class EmailContentSensor(unittest.TestCase):
FakeEMailReader(deque([test_message])),
"test_emails_sensor",
["sender@test.com"],
"{{ subject }} from {{ from }} with message {{ body }}")
Template("{{ subject }} from {{ from }} with message {{ body }}",
self.hass))
sensor.entity_id = "sensor.emailtest"
sensor.update()