'Test for firing on change with template.'

def test_if_fires_on_change_with_template_2(self):

    assert setup_component(self.hass, automation.DOMAIN, {automation.DOMAIN: {'trigger': {'platform': 'template', 'value_template': '{{    not    is_state("test.entity",    "world")    }}'}, 'action': {'service': 'test.automation'}}})
    self.hass.block_till_done()
    self.calls = []
    self.hass.states.set('test.entity', 'world')
    self.hass.block_till_done()
    assert (len(self.calls) == 0)
    self.hass.states.set('test.entity', 'home')
    self.hass.block_till_done()
    assert (len(self.calls) == 1)
    self.hass.states.set('test.entity', 'work')
    self.hass.block_till_done()
    assert (len(self.calls) == 1)
    self.hass.states.set('test.entity', 'not_home')
    self.hass.block_till_done()
    assert (len(self.calls) == 1)
    self.hass.states.set('test.entity', 'world')
    self.hass.block_till_done()
    assert (len(self.calls) == 1)
    self.hass.states.set('test.entity', 'home')
    self.hass.block_till_done()
    assert (len(self.calls) == 2)
