'Test fire event.'

def test_fire_event(self):

    self.assertTrue(setup_component(self.hass, 'rfxtrx', {'rfxtrx': {'device': ('/dev/serial/by-id/usb' + '-RFXCOM_RFXtrx433_A1Y0NJGR-if00-port0'), 'dummy': True}}))
    self.assertTrue(setup_component(self.hass, 'switch', {'switch': {'platform': 'rfxtrx', 'automatic_add': True, 'devices': {'0b1100cd0213c7f210010f51': {'name': 'Test', rfxtrx.ATTR_FIREEVENT: True}}}}))
    calls = []
    @callback
    def record_event(event):
        'Add    recorded    event    to    set.'
        calls.append(event)
    self.hass.bus.listen(rfxtrx.EVENT_BUTTON_PRESSED, record_event)
    self.hass.block_till_done()
    entity = rfxtrx.RFX_DEVICES['213c7f216']
    self.assertEqual('Test', entity.name)
    self.assertEqual('off', entity.state)
    self.assertTrue(entity.should_fire_event)
    event = rfxtrx.get_rfx_object('0b1100cd0213c7f210010f51')
    event.data = bytearray([11, 17, 0, 16, 1, 24, 205, 234, 1, 1, 15, 112])
    rfxtrx.RECEIVED_EVT_SUBSCRIBERS[0](event)
    self.hass.block_till_done()
    self.assertEqual(event.values['Command'], 'On')
    self.assertEqual('on', entity.state)
    self.assertEqual(self.hass.states.get('switch.test').state, 'on')
    self.assertEqual(1, len(calls))
    self.assertEqual(calls[0].data, {'entity_id': 'switch.test', 'state': 'on'})
