'Test for firing on entity change.'

def test_if_fires_on_entity_change(self):

    self.hass.states.set('test.entity', 'hello')
    self.hass.block_till_done()
    assert setup_component(self.hass, automation.DOMAIN, {automation.DOMAIN: {'trigger': {'platform': 'state', 'entity_id': 'test.entity'}, 'action': {'service': 'test.automation', 'data_template': {'some': ('{{    trigger.%s    }}' % '}}    -    {{    trigger.'.join(('platform', 'entity_id', 'from_state.state', 'to_state.state', 'for')))}}}})
    self.hass.states.set('test.entity', 'world')
    self.hass.block_till_done()
    self.assertEqual(1, len(self.calls))
    self.assertEqual('state    -    test.entity    -    hello    -    world    -    None', self.calls[0].data['some'])
    automation.turn_off(self.hass)
    self.hass.block_till_done()
    self.hass.states.set('test.entity', 'planet')
    self.hass.block_till_done()
    self.assertEqual(1, len(self.calls))
