41f205e09d54a968f162dd36c63c3641a703b672,homeassistant/components/switch/template.py,SwitchTemplate,update,#SwitchTemplate#,136
Before Change
Update the state from the template.
try:
self._value = template.render(self.hass, self._template)
if not self.available:
_LOGGER.error(
"`%s` is not a switch state, setting %s to unavailable",
self._value, self.entity_id)
except TemplateError as ex:
self._value = STATE_ERROR
_LOGGER.error(ex)
After Change
try:
state = template.render(self.hass, self._template).lower()
if state in _VALID_STATES:
self._state = state in ("true", STATE_ON)
else:
_LOGGER.error(
"Received invalid switch is_on state: %s. Expected: %s",
state, ", ".join(_VALID_STATES))
self._state = None
except TemplateError as ex:
_LOGGER.error(ex)
self._state = None
In pattern: SUPERPATTERN
Frequency: 5
Non-data size: 4
Instances
Project Name: home-assistant/home-assistant
Commit Name: 41f205e09d54a968f162dd36c63c3641a703b672
Time: 2016-03-24
Author: paulus@paulusschoutsen.nl
File Name: homeassistant/components/switch/template.py
Class Name: SwitchTemplate
Method Name: update
Project Name: home-assistant/home-assistant
Commit Name: 3bd37d6a657ff676c919515784cdb631c138e754
Time: 2019-04-02
Author: david@bonnes.me
File Name: homeassistant/components/evohome/__init__.py
Class Name:
Method Name: setup
Project Name: home-assistant/home-assistant
Commit Name: 646618a25e44c98a8bba0c7cceb9dd074698adc1
Time: 2015-11-14
Author: fabian@affolter-engineering.ch
File Name: homeassistant/components/sensor/glances.py
Class Name:
Method Name: setup_platform
Project Name: home-assistant/home-assistant
Commit Name: 2863c2d593184ba4edfda242892b50b466cedcf6
Time: 2015-03-21
Author: paulus@paulusschoutsen.nl
File Name: homeassistant/bootstrap.py
Class Name:
Method Name: setup_component
Project Name: home-assistant/home-assistant
Commit Name: 09d531b3b95e7943df53233d1abcb40d7e87de94
Time: 2016-08-18
Author: nkgilley@gmail.com
File Name: homeassistant/components/media_player/gpmdp.py
Class Name:
Method Name: setup_platform