'Check IOError exception error message.'

@patch('pilight.pilight.Client', PilightDaemonSim)
@patch('homeassistant.components.pilight._LOGGER.error')
def test_send_code_fail(self, mock_pilight_error):

    with assert_setup_component(4):
        with patch('pilight.pilight.Client.send_code', side_effect=IOError):
            self.assertTrue(setup_component(self.hass, pilight.DOMAIN, {pilight.DOMAIN: {}}))
            service_data = {'protocol': 'test', 'value': 42}
            self.hass.services.call(pilight.DOMAIN, pilight.SERVICE_NAME, service_data=service_data, blocking=True)
            self.hass.block_till_done()
            error_log_call = mock_pilight_error.call_args_list[(-1)]
            self.assertTrue(('Pilight    send    failed' in str(error_log_call)))
