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
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 6

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: 5d3e92959940f679150accb01d92c99e6b92ba83
Time: 2015-09-10
Author: fabian@affolter-engineering.ch
File Name: homeassistant/components/switch/arest.py
Class Name: ArestSwitch
Method Name: turn_off


Project Name: home-assistant/home-assistant
Commit Name: 5d3e92959940f679150accb01d92c99e6b92ba83
Time: 2015-09-10
Author: fabian@affolter-engineering.ch
File Name: homeassistant/components/switch/arest.py
Class Name: ArestSwitch
Method Name: turn_on