Fix template light returning NULL in color or temperature (#33498)

* Support for returning NULL in color or temperature. Fixes #33469

* Added further support for ‘None’ returns in level template

* Removed assumption that template render may not be a string

* Streamlined code per cloud pylint

* Updates per code review suggestions

* Added improved error handling and logging for brightness

* Additional exception handling for temperature
This commit is contained in:
Alistair Galbraith authored and GitHub committed 2020-04-02 17:41:19 -05:00
1 parent 8fbdc703e0
commit 3db9d6a6aa
2 files changed
+48 -10

No files matched your search

+17 -2
View File
@@ -543,7 +543,13 @@ class TestTemplateLight:
@pytest.mark.parametrize(
"expected_level,template",
[(255, "{{255}}"), (None, "{{256}}"), (None, "{{x - 12}}")],
[
(255, "{{255}}"),
(None, "{{256}}"),
(None, "{{x - 12}}"),
(None, "{{ none }}"),
(None, ""),
],
)
def test_level_template(self, expected_level, template):
"""Test the template for the level."""
@@ -588,7 +594,14 @@ class TestTemplateLight:
@pytest.mark.parametrize(
"expected_temp,template",
[(500, "{{500}}"), (None, "{{501}}"), (None, "{{x - 12}}")],
[
(500, "{{500}}"),
(None, "{{501}}"),
(None, "{{x - 12}}"),
(None, "None"),
(None, "{{ none }}"),
(None, ""),
],
)
def test_temperature_template(self, expected_temp, template):
"""Test the template for the temperature."""
@@ -894,6 +907,8 @@ class TestTemplateLight:
(None, "{{(361, 100)}}"),
(None, "{{(360, 101)}}"),
(None, "{{x - 12}}"),
(None, ""),
(None, "{{ none }}"),
],
)
def test_color_template(self, expected_hs, template):